umami/next.config.js

72 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-07-17 10:03:38 +02:00
require('dotenv').config();
const pkg = require('./package.json');
2020-07-17 10:03:38 +02:00
2022-08-01 08:29:47 +02:00
const contentSecurityPolicy = `
default-src 'self';
img-src *;
script-src 'self' 'unsafe-eval';
style-src 'self' 'unsafe-inline';
connect-src 'self' api.umami.is;
frame-ancestors 'self';
`;
const headers = [
{
key: 'X-DNS-Prefetch-Control',
value: 'on',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'Content-Security-Policy',
value: contentSecurityPolicy.replace(/\s{2,}/g, ' ').trim(),
},
];
if (process.env.FORCE_SSL) {
headers.push({
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
});
}
2020-07-17 10:03:38 +02:00
module.exports = {
env: {
2022-06-24 10:54:55 +02:00
currentVersion: pkg.version,
isProduction: process.env.NODE_ENV === 'production',
2022-10-13 01:29:44 +02:00
isCloudMode: process.env.CLOUD_MODE,
2020-09-27 05:46:20 +02:00
},
2022-02-19 06:30:41 +01:00
basePath: process.env.BASE_PATH,
2022-07-07 18:24:32 +02:00
output: 'standalone',
2021-11-22 23:53:36 +01:00
eslint: {
ignoreDuringBuilds: true,
},
2020-07-17 10:03:38 +02:00
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
2021-07-13 05:25:24 +02:00
issuer: /\.js$/,
2020-07-17 10:03:38 +02:00
use: ['@svgr/webpack'],
});
return config;
},
async headers() {
return [
2022-08-01 08:29:47 +02:00
{
source: '/:path*',
headers,
},
2022-08-02 09:24:17 +02:00
];
},
async rewrites() {
return [
{
2022-08-02 09:24:17 +02:00
source: '/telemetry.js',
destination: '/api/scripts/telemetry',
},
2020-12-04 07:28:05 +01:00
];
},
2020-07-17 10:03:38 +02:00
};