Skip to content

Open-source status page, incident response and uptime monitoring

fix: add csp headers (#2052)

Thibault Le Ouay7ab47247e614
diff --git a/apps/status-page/next.config.ts b/apps/status-page/next.config.ts
index f56632512..fd80cd2a4 100644
--- a/apps/status-page/next.config.ts
+++ b/apps/status-page/next.config.ts
@@ -3,6 +3,21 @@ import type { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin";
import { defaultLocale, locales } from "./src/i18n/config";
+const isDev = process.env.NODE_ENV === "development";
+
+const cspHeader = `
+ default-src 'self';
+ script-src 'self' 'unsafe-inline'${isDev ? " 'unsafe-eval'" : ""};
+ style-src 'self' 'unsafe-inline';
+ img-src 'self' blob: data:;
+ font-src 'self';
+ object-src 'none';
+ base-uri 'self';
+ form-action 'self';
+ frame-ancestors 'none';
+ upgrade-insecure-requests;
+ `;
+
const withNextIntl = createNextIntlPlugin({
requestConfig: "./src/i18n/request.ts",
experimental: {
@@ -34,6 +49,19 @@ const nextConfig: NextConfig = {
fullUrl: true,
},
},
+ async headers() {
+ return [
+ {
+ source: "/(.*)",
+ headers: [
+ {
+ key: "Content-Security-Policy",
+ value: cspHeader.replace(/\n/g, ""),
+ },
+ ],
+ },
+ ];
+ },
};
// For detailed options, refer to the official documentation: