Skip to content

Commit

Permalink
feat(web): add security headers
Browse files Browse the repository at this point in the history
  • Loading branch information
cstrnt committed Jul 25, 2024
1 parent da5695d commit 40055b1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions apps/web/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ const withBundleAnalyzer = bundleAnalzyer({
*/
!process.env.SKIP_ENV_VALIDATION && (await import("./src/env/server.mjs"));

const cspHeader = `
default-src 'self';
script-src 'self' 'unsafe-eval' 'unsafe-inline';
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;
`;

/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,
Expand All @@ -44,6 +57,19 @@ const config = {
experimental: {
instrumentationHook: true,
},
async headers() {
return [
{
source: "/(.*)",
headers: [
{
key: "Content-Security-Policy",
value: cspHeader.replace(/\n/g, ""),
},
],
},
];
},
};

export default withPlausibleProxy()(
Expand Down

0 comments on commit 40055b1

Please sign in to comment.