77 lines
2.5 KiB
TypeScript
77 lines
2.5 KiB
TypeScript
import type { NextConfig } from "next";
|
|
|
|
// Basemap (CartoDB Positron via MapLibre) hosts used by the client.
|
|
const MAP_TILE_HOSTS = "https://basemaps.cartocdn.com https://*.basemaps.cartocdn.com";
|
|
|
|
// Opt-in sub-path support: empty for standalone/root deployments (unchanged),
|
|
// set to e.g. "/dashboards/laadpalen" at build time for the wegoze portal.
|
|
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
|
|
|
const nextConfig: NextConfig = {
|
|
compress: true,
|
|
...(basePath ? { basePath } : {}),
|
|
|
|
async headers() {
|
|
const securityHeaders = [
|
|
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
{ key: "X-XSS-Protection", value: "1; mode=block" },
|
|
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
|
|
];
|
|
|
|
const csp = (frameAncestors: string) =>
|
|
[
|
|
"default-src 'self'",
|
|
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com",
|
|
"style-src 'self' 'unsafe-inline'",
|
|
`img-src 'self' data: blob: https://logo.clearbit.com ${MAP_TILE_HOSTS}`,
|
|
"font-src 'self' data:",
|
|
`connect-src 'self' https://va.vercel-scripts.com ${MAP_TILE_HOSTS}`,
|
|
"worker-src 'self' blob:",
|
|
"child-src 'self' blob:",
|
|
`frame-ancestors ${frameAncestors}`,
|
|
].join("; ");
|
|
|
|
return [
|
|
{
|
|
source: "/embed",
|
|
headers: [
|
|
...securityHeaders,
|
|
{ key: "Content-Security-Policy", value: csp("*") },
|
|
],
|
|
},
|
|
{
|
|
source: "/((?!embed).*)",
|
|
headers: [
|
|
...securityHeaders,
|
|
{ key: "X-Frame-Options", value: "DENY" },
|
|
{ key: "Content-Security-Policy", value: csp("'none'") },
|
|
],
|
|
},
|
|
{
|
|
// Crop-out + national GeoJSON: cache 1 hour.
|
|
source: "/data/:path*.geojson",
|
|
headers: [
|
|
{ key: "Cache-Control", value: "public, max-age=3600, must-revalidate" },
|
|
{ key: "Content-Type", value: "application/geo+json" },
|
|
],
|
|
},
|
|
{
|
|
// Per-gemeente detail bundles: cache 1 hour + SWR.
|
|
source: "/data/:path*.json",
|
|
headers: [
|
|
{ key: "Cache-Control", value: "public, max-age=3600, stale-while-revalidate=86400" },
|
|
],
|
|
},
|
|
{
|
|
source: "/municipalities.json",
|
|
headers: [
|
|
{ key: "Cache-Control", value: "public, max-age=86400, stale-while-revalidate=3600" },
|
|
],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|