Hello, I was trying to add security headers to my sveltekit web app:
const handleSecurityHeaders: Handle = async ({ event, resolve }) => {
const response = await resolve(event)
response.headers.set('X-Frame-Options', 'DENY')
response.headers.set('X-Content-Type-Options', 'nosniff')
response.headers.set('Referrer-Policy', 'no-referrer-when-downgrade')
response.headers.set('Permissions-Policy', 'camera=(), microphone=(), geolocation=()')
response.headers.set('Access-Control-Allow-Origin', config.site_url || '*')
return response
}
the headers appear when I’m in dev mode but when I deploy it to Vercel I can’t see them until I add them to vercel.json
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "Access-Control-Allow-Origin", "value": "https://islamzaoui.top" },
{ "key": "X-Frame-Options", "value": "SAMEORIGIN" },
{ "key": "X-Content-Type-Options", "value": "nosniff" },
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" },
{ "key": "Permissions-Policy", "value": "geolocation=(), camera=(), microphone=()" }
]
}
]
}
any suggestions?