Skip to content

Commit

Permalink
Add CSP to Bull Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Apr 14, 2024
1 parent 12cf8c6 commit 00cb702
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/backend/src/server/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ app.use(async (ctx, next) => {
// %71ueueとかでリクエストされたら困るため
const url = decodeURI(ctx.path);
if (url === bullBoardPath || url.startsWith(bullBoardPath + '/')) {
ctx.set('Content-Security-Policy',
`base-uri 'self'; `
+ `default-src 'none'; `
+ `script-src 'self'; `
+ `img-src 'self' https: data: blob:; `
+ `style-src 'self' 'unsafe-inline' https:; `
+ `font-src 'self' https:; `
+ `connect-src 'self' data: blob:; `
+ `frame-ancestors 'none'`);

if (!url.startsWith(bullBoardPath + '/static/')) {
ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
}
Expand Down

0 comments on commit 00cb702

Please sign in to comment.