53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import type { NextConfig } from "next";
|
|
import bundleAnalyzer from '@next/bundle-analyzer';
|
|
|
|
const withBundleAnalyzer = bundleAnalyzer({
|
|
enabled: process.env.ANALYZE === 'true',
|
|
});
|
|
|
|
const cspHeader = `
|
|
default-src 'self';
|
|
script-src 'self' 'unsafe-eval' 'unsafe-inline' https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/ https://www.googletagmanager.com https://www.clarity.ms;
|
|
style-src 'self' 'unsafe-inline';
|
|
img-src 'self' blob: data: https://images.unsplash.com https://placehold.co https://c.bing.com https://www.google-analytics.com;
|
|
font-src 'self';
|
|
connect-src 'self' https://www.google-analytics.com https://*.clarity.ms;
|
|
frame-src 'self' https://www.google.com/recaptcha/ https://recaptcha.google.com/recaptcha/;
|
|
object-src 'none';
|
|
base-uri 'self';
|
|
form-action 'self';
|
|
frame-ancestors 'none';
|
|
upgrade-insecure-requests;
|
|
`.replace(/\s{2,}/g, ' ').trim();
|
|
|
|
const nextConfig: NextConfig = {
|
|
experimental: {
|
|
optimizeCss: true,
|
|
},
|
|
images: {
|
|
remotePatterns: [
|
|
{ protocol: 'https', hostname: 'images.unsplash.com' },
|
|
{ protocol: 'https', hostname: 'placehold.co' },
|
|
{ protocol: 'http', hostname: 'localhost' },
|
|
],
|
|
},
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: '/(.*)',
|
|
headers: [
|
|
{ key: 'X-Content-Type-Options', value: 'nosniff' },
|
|
{ key: 'X-Frame-Options', value: 'DENY' },
|
|
{ key: 'X-XSS-Protection', value: '1; mode=block' },
|
|
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
|
|
{ key: 'Content-Security-Policy', value: cspHeader },
|
|
{ key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubDomains; preload' },
|
|
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
|
|
],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default withBundleAnalyzer(nextConfig);
|