web: generate _headers & add Content-Security-Policy header

This commit is contained in:
wukko 2024-09-18 18:44:24 +06:00
parent d1686be583
commit 97977efabd
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
2 changed files with 28 additions and 3 deletions

View file

@ -0,0 +1,28 @@
export async function GET() {
const CSP = [
"default-src 'none'",
"script-src 'self' challenges.cloudflare.com",
"frame-src challenges.cloudflare.com",
]
const _headers = {
"/*": {
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "require-corp",
"Content-Security-Policy": CSP.join("; "),
}
}
return new Response(
Object.entries(_headers).map(
([path, headers]) => [
path,
Object.entries(headers).map(
([key, value]) => ` ${key}: ${value}`
)
].flat().join("\n")
).join("\n\n")
);
}
export const prerender = true;

View file

@ -1,3 +0,0 @@
/*
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp