ente/next.config.js

77 lines
2.6 KiB
JavaScript
Raw Normal View History

2020-10-03 14:21:56 +00:00
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
2021-06-15 19:07:01 +00:00
const withWorkbox = require('@ente-io/next-with-workbox');
2021-06-07 10:45:46 +00:00
const { withSentryConfig } = require('@sentry/nextjs');
2021-03-08 11:59:14 +00:00
2021-06-15 09:07:32 +00:00
const cp = require('child_process');
const gitSha = cp.execSync('git rev-parse --short HEAD', {
cwd: __dirname,
encoding: 'utf8',
});
2021-03-08 11:59:14 +00:00
2021-11-30 11:44:44 +00:00
const { createSecureHeaders } = require('next-secure-headers');
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({
env: {
SENTRY_RELEASE: gitSha,
},
workbox: {
swSrc: 'src/serviceWorker.js',
exclude: [/manifest\.json$/i],
},
2021-09-07 11:51:49 +00:00
// added to enabled shared Array buffer - https://web.dev/coop-coep/
2021-08-29 13:32:58 +00:00
headers() {
return [
{
2021-08-29 12:48:26 +00:00
// Apply these headers to all routes in your application....
2021-08-29 14:03:30 +00:00
source: '/(.*)',
2021-11-30 11:44:44 +00:00
headers: [
...COOP_COEP_HEADERS,
...createSecureHeaders({
contentSecurityPolicy: {
2021-12-01 13:06:45 +00:00
reportOnly: true,
2021-11-30 11:44:44 +00:00
directives: {
2021-12-01 13:06:45 +00:00
defaultSrc: `'self'`,
frameAncestors: `'self'`,
objectSrc: `'none'`,
baseURI: `'self'`,
formAction: `'self'`,
reportURI:
'https://csp-reporter.ente.workers.dev',
reportTo:
'https://csp-reporter.ente.workers.dev',
2021-11-30 11:44:44 +00:00
},
},
}),
],
},
];
},
2021-09-07 11:51:49 +00:00
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback.fs = false;
}
return config;
},
})
),
{ release: gitSha }
);