feat: apply status page CSP to custom domains

Detect custom domains by comparing the request host to the app host and apply
the tightened CSP there too, not just on the public path. Run the middleware
before express.static so static-served root documents get the header, and keep
helmet after static so its default-src does not block custom domain API calls.
This commit is contained in:
Buco7854 committed 2026-06-24 18:21:16 +00:00
1 parent ffbf223288
commit a4cc322a55
3 files changed
+51 -20

No files matched your search

+3 -2
View File
@@ -14,7 +14,7 @@ import { InitializedControllers } from "@/config/controllers.js";
import { EnvConfig } from "@/domain/app-settings/app-settings.service.js";
import { createStatusPageCorsOrigin } from "@/api/middleware/statusPageCorsOrigin.js";
import { isPublicStatusPageApiPath } from "@/api/middleware/statusPagePublicApiPath.js";
import { statusPageDocumentCsp } from "@/api/middleware/statusPageDocumentCsp.js";
import { createStatusPageDocumentCsp } from "@/api/middleware/statusPageDocumentCsp.js";
export const createApp = ({
services,
@@ -49,6 +49,8 @@ export const createApp = ({
return cors(corsOptions)(req, res, next);
});
app.use(createStatusPageDocumentCsp(allowedOrigin));
app.use(express.static(frontendPath));
app.use(express.json());
@@ -71,7 +73,6 @@ export const createApp = ({
},
})
);
app.use(statusPageDocumentCsp);
app.use(
compression({
level: 6,