Skip to content

Commit

Permalink
Use standard CSP for generated 404 pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Nov 19, 2024
1 parent 107308c commit 524dae7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app-www.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ app.use(async function strictContentSecurityPolicy(ctx, next) {
const buf = randomBytes(6);
const nonce = ctx.state.nonce = buf.toString('base64url');
await next();
if (ctx.status === 200 && ctx.type === 'text/html') {
const status = ctx.status;
if ((status === 200 || status === 404) && ctx.type === 'text/html') {
const csp = `script-src 'nonce-${nonce}' 'strict-dynamic' https: 'unsafe-inline';` +
` style-src 'self' https: data: 'unsafe-inline';` +
` frame-ancestors https: data:;` +
Expand Down

0 comments on commit 524dae7

Please sign in to comment.