Ver código fonte

add coep header for /_next/static/chunks/:any routes

Abhinav-grd 3 anos atrás
pai
commit
7031b302ca
1 arquivos alterados com 26 adições e 0 exclusões
  1. 26 0
      next.config.js

+ 26 - 0
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 }