69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
import type { NextConfig } from "next";
|
|
import webpack from "webpack";
|
|
|
|
const nextConfig: NextConfig = {
|
|
output: "standalone",
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/(.*)",
|
|
headers: [
|
|
{
|
|
key: "Content-Security-Policy",
|
|
value: [
|
|
"default-src 'self'",
|
|
// CesiumJS requires unsafe-eval (worker compilation) and unsafe-inline (styles)
|
|
"script-src 'self' 'unsafe-eval' 'unsafe-inline' blob:",
|
|
"style-src 'self' 'unsafe-inline' fonts.googleapis.com",
|
|
"font-src 'self' fonts.gstatic.com",
|
|
"img-src 'self' data: blob: *.tile.openstreetmap.org *.arcgisonline.com *.virtualearth.net *.bing.com *.googleapis.com",
|
|
"connect-src 'self' *.supabase.co *.worldwideview.dev *.cesium.com *.arcgisonline.com *.virtualearth.net *.googleapis.com *.vercel-scripts.com",
|
|
"worker-src 'self' blob:",
|
|
"frame-ancestors 'none'",
|
|
].join("; "),
|
|
},
|
|
{ key: "X-Frame-Options", value: "DENY" },
|
|
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
{ key: "X-DNS-Prefetch-Control", value: "on" },
|
|
{
|
|
key: "Permissions-Policy",
|
|
value: "camera=(), microphone=(), geolocation=(self)",
|
|
},
|
|
],
|
|
},
|
|
];
|
|
},
|
|
outputFileTracingExcludes: {
|
|
"*": ["./public/cesium/**"],
|
|
},
|
|
env: {
|
|
CESIUM_BASE_URL: "/cesium",
|
|
},
|
|
webpack: (config, { isServer }) => {
|
|
if (!isServer) {
|
|
// Define CESIUM_BASE_URL for Cesium's worker resolution
|
|
config.plugins?.push(
|
|
new webpack.DefinePlugin({
|
|
CESIUM_BASE_URL: JSON.stringify("/cesium"),
|
|
})
|
|
);
|
|
|
|
// Cesium uses some Node.js modules that should be excluded in the browser
|
|
config.resolve = config.resolve || {};
|
|
config.resolve.fallback = {
|
|
...config.resolve.fallback,
|
|
fs: false,
|
|
http: false,
|
|
https: false,
|
|
zlib: false,
|
|
url: false,
|
|
};
|
|
}
|
|
|
|
return config;
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|