From 7031b302ca03ec845c372ef5faeccaa6cceb36b3 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 29 Aug 2021 17:59:46 +0530 Subject: [PATCH] add coep header for /_next/static/chunks/:any routes --- next.config.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/next.config.js b/next.config.js index 1d20f2783..a878c4bc8 100644 --- a/next.config.js +++ b/next.config.js @@ -11,6 +11,18 @@ const gitSha = cp.execSync('git rev-parse --short HEAD', { encoding: 'utf8', }); +// eslint-disable-next-line camelcase +const COOP_COEP_Headers = [ + { + key: 'Cross-Origin-Opener-Policy', + value: 'same-origin', + }, + { + key: 'Cross-Origin-Embedder-Policy', + value: 'require-corp', + }, +]; + module.exports = withSentryConfig( withWorkbox( withBundleAnalyzer({ @@ -29,6 +41,20 @@ module.exports = withSentryConfig( 'static/webpack/[fullhash].[runtime].hot-update.json'; return config; }, + + async headers() { + return [ + { + // Apply these headers to all routes in your application. + source: '/(.*)', + headers: COOP_COEP_Headers, + }, + { + source: '/_next/static/chunks/:any', + headers: COOP_COEP_Headers, + }, + ]; + }, }) ), { release: gitSha }