mirror of
https://github.com/jakejarvis/hoot.git
synced 2025-10-18 20:14:25 -04:00
Add Content Security Policy headers for production environment
This commit is contained in:
@@ -35,6 +35,48 @@ const nextConfig: NextConfig = {
|
||||
},
|
||||
];
|
||||
},
|
||||
headers: async () => {
|
||||
return process.env.VERCEL_ENV === "production"
|
||||
? [
|
||||
{
|
||||
source: "/:path*",
|
||||
headers: [
|
||||
{
|
||||
key: "Content-Security-Policy-Report-Only",
|
||||
value: `
|
||||
default-src 'self';
|
||||
script-src 'self' 'unsafe-eval' 'unsafe-inline' https://*.posthog.com https://vercel.live https://vitals.vercel-insights.com;
|
||||
style-src 'self' 'unsafe-inline' https://vercel.live;
|
||||
img-src 'self' https://f2zros4g9k.ufs.sh https://vercel.live https://vercel.com data: blob:;
|
||||
font-src 'self' https://vercel.live https://assets.vercel.com;
|
||||
object-src 'none';
|
||||
connect-src 'self' https://*.posthog.com https://*.tiles.mapbox.com https://api.mapbox.com https://events.mapbox.com https://vercel.live https://vitals.vercel-insights.com https://*.pusher.com wss://*.pusher.com;
|
||||
worker-src 'self' data: blob:;
|
||||
child-src 'self' blob:;
|
||||
frame-src 'self' https://vercel.live;
|
||||
frame-ancestors 'none';
|
||||
form-action 'self';
|
||||
base-uri 'self';
|
||||
${
|
||||
process.env.NEXT_PUBLIC_POSTHOG_KEY
|
||||
? `report-uri https://us.i.posthog.com/report/?token=${process.env.NEXT_PUBLIC_POSTHOG_KEY}; report-to posthog`
|
||||
: ""
|
||||
}
|
||||
`
|
||||
.replace(/\s{2,}/g, " ")
|
||||
.trim(),
|
||||
},
|
||||
{
|
||||
key: "Reporting-Endpoints",
|
||||
value: process.env.NEXT_PUBLIC_POSTHOG_KEY
|
||||
? `posthog="https://us.i.posthog.com/report/?token=${process.env.NEXT_PUBLIC_POSTHOG_KEY}"`
|
||||
: "",
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
: [];
|
||||
},
|
||||
skipTrailingSlashRedirect: true,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user