Skip to content

Commit 9acfa66

Browse files
Klakurkachedieck
andauthored
Added security headers to prevent clickjacking on sign in (#1068)
* Added security headers. * refactor: stricter policy * fix: contradicting policy * refactor: reident * refactor: nit --------- Co-authored-by: Estevão <estevao@chedieck.com>
1 parent 55e10cb commit 9acfa66

File tree

1 file changed

+52
-41
lines changed

1 file changed

+52
-41
lines changed

next.config.js

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
11
const paybuttonConfig = require('./paybutton-config.json')
22

33
const {
4-
PHASE_DEVELOPMENT_SERVER,
5-
PHASE_PRODUCTION_BUILD,
6-
PHASE_PRODUCTION_SERVER,
7-
} = require('next/constants')
8-
9-
// This uses phases as outlined here: https://nextjs.org/docs/#custom-configuration
10-
module.exports = (phase) => {
11-
// when started in development mode `next dev` or `npm run dev` regardless of the value of STAGING environmental variable
12-
const isDev = phase === PHASE_DEVELOPMENT_SERVER
13-
// when `next build` or `npm run build` is used
14-
const isBuild = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING !== '1'
15-
// when `next start` or `npm run start` is used
16-
const isProd = phase === PHASE_PRODUCTION_SERVER
17-
// when `next build` or `npm run build` is used
18-
const isStaging =
19-
phase === PHASE_PRODUCTION_BUILD && process.env.STAGING === '1'
20-
21-
const branch = process.env.BRANCH || 'master'
22-
console.log(`branch: ${branch}\nisDev:${isDev} isBuild:${isBuild} isProd:${isProd} isStaging:${isStaging}`)
23-
24-
return {
25-
outputFileTracing: true,
26-
eslint: {
27-
ignoreDuringBuilds: true
28-
},
29-
typescript: {
30-
ignoreBuildErrors: true
31-
},
32-
async rewrites() {
33-
return [
34-
{
35-
source: '/:path*',
36-
destination: '/:path*',
37-
},
38-
{
39-
source: '/:path*',
40-
destination: `/api/:path*`,
41-
},
42-
]
43-
},
44-
}
4+
PHASE_DEVELOPMENT_SERVER,
5+
PHASE_PRODUCTION_BUILD,
6+
PHASE_PRODUCTION_SERVER,
7+
} = require('next/constants')
8+
9+
// This uses phases as outlined here: https://nextjs.org/docs/#custom-configuration
10+
module.exports = (phase) => {
11+
// when started in development mode `next dev` or `npm run dev` regardless of the value of STAGING environmental variable
12+
const isDev = phase === PHASE_DEVELOPMENT_SERVER
13+
// when `next build` or `npm run build` is used
14+
const isBuild = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING !== '1'
15+
// when `next start` or `npm run start` is used
16+
const isProd = phase === PHASE_PRODUCTION_SERVER
17+
// when `next build` or `npm run build` is used
18+
const isStaging =
19+
phase === PHASE_PRODUCTION_BUILD && process.env.STAGING === '1'
20+
21+
const branch = process.env.BRANCH || 'master'
22+
console.log(`branch: ${branch}\nisDev:${isDev} isBuild:${isBuild} isProd:${isProd} isStaging:${isStaging}`)
23+
24+
return {
25+
outputFileTracing: true,
26+
eslint: {
27+
ignoreDuringBuilds: true
28+
},
29+
typescript: {
30+
ignoreBuildErrors: true
31+
},
32+
async headers () {
33+
return [
34+
{
35+
source: '/(.*)',
36+
headers: [
37+
{ key: 'X-Frame-Options', value: 'DENY' },
38+
{ key: 'Content-Security-Policy', value: "frame-ancestors 'none'" },
39+
],
40+
},
41+
]
42+
},
43+
async rewrites () {
44+
return [
45+
{
46+
source: '/:path*',
47+
destination: '/:path*',
48+
},
49+
{
50+
source: '/:path*',
51+
destination: `/api/:path*`,
52+
},
53+
]
54+
},
4555
}
56+
}

0 commit comments

Comments
 (0)