Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
adds next-secure-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavkgrd committed Nov 30, 2021
1 parent 24fcbb3 commit ce22b0f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
20 changes: 17 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const gitSha = cp.execSync('git rev-parse --short HEAD', {
encoding: 'utf8',
});

// eslint-disable-next-line camelcase
const COOP_COEP_Headers = [
const { createSecureHeaders } = require('next-secure-headers');

const COOP_COEP_HEADERS = [
{
key: 'Cross-Origin-Opener-Policy',
value: 'same-origin',
Expand Down Expand Up @@ -40,7 +41,20 @@ module.exports = withSentryConfig(
{
// Apply these headers to all routes in your application....
source: '/(.*)',
headers: COOP_COEP_Headers,
headers: [
...COOP_COEP_HEADERS,
...createSecureHeaders({
contentSecurityPolicy: {
directives: {
defaultSrc: 'self',
frameAncestors: 'self',
objectSrc: 'self',
baseURI: 'self',
formAction: 'self',
},
},
}),
],
},
];
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"eslint-plugin-react": "^7.23.2",
"husky": "^7.0.1",
"lint-staged": "^11.1.2",
"next-secure-headers": "^2.2.0",
"prettier": "2.3.2",
"typescript": "^4.1.3"
},
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4613,6 +4613,11 @@ [email protected]:
resolved "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz"
integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==

next-secure-headers@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/next-secure-headers/-/next-secure-headers-2.2.0.tgz#d4eb1b00a424f811c1455d1288990a4aad3026af"
integrity sha512-C7OfZ9JdSJyYMz2ZBMI/WwNbt0qNjlFWX9afUp8nEUzbz6ez3JbeopdyxSZJZJAzVLIAfyk6n73rFpd4e22jRg==

next@^11.1.2:
version "11.1.2"
resolved "https://registry.npmjs.org/next/-/next-11.1.2.tgz"
Expand Down

0 comments on commit ce22b0f

Please sign in to comment.