Skip to content

Commit

Permalink
Move header back to next config
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Dec 26, 2023
1 parent 148ed54 commit 7874f12
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 80 deletions.
39 changes: 33 additions & 6 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@ const { version } = require('./package.json')

const isDev = process.env.NODE_ENV !== 'production'

const CONNECT_SRC_HOSTS = [
'https://*.celo.org',
'https://*.celoscan.io',
'https://*.walletconnect.com',
'wss://*.walletconnect.com',
'wss://*.walletconnect.org',
'https://raw.githubusercontent.com',
'https://celo-mainnet.infura.io',
];
const FRAME_SRC_HOSTS = ['https://*.walletconnect.com', 'https://*.walletconnect.org'];
const IMG_SRC_HOSTS = ['https://raw.githubusercontent.com', 'https://*.walletconnect.com'];

const cspHeader = `
default-src 'self';
script-src 'self'${isDev ? " 'unsafe-eval'" : ''};
script-src-elem 'self' 'unsafe-inline';
style-src 'self' 'unsafe-inline';
connect-src 'self' ${CONNECT_SRC_HOSTS.join(' ')};
img-src 'self' blob: data: ${IMG_SRC_HOSTS.join(' ')};
font-src 'self' data:;
object-src 'none';
base-uri 'self';
form-action 'self';
frame-src 'self' ${FRAME_SRC_HOSTS.join(' ')};
frame-ancestors 'none';
${!isDev ? 'block-all-mixed-content;' : ''}
${!isDev ? 'upgrade-insecure-requests;' : ''}
`.replace(/\s{2,}/g, ' ').trim()

const securityHeaders = [
{
key: 'X-XSS-Protection',
Expand All @@ -21,12 +50,10 @@ const securityHeaders = [
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
// {
// // Note: This is a fallback default CSP.
// // See middleware.ts for the actual CSP
// key: 'Content-Security-Policy',
// value: `default-src 'self';`,
// },
{
key: 'Content-Security-Policy',
value: cspHeader,
},
]

module.exports = {
Expand Down
74 changes: 0 additions & 74 deletions src/middleware.ts

This file was deleted.

0 comments on commit 7874f12

Please sign in to comment.