From f03caeb7cbe8cd427b7f436e87ff517105040606 Mon Sep 17 00:00:00 2001 From: Sander Saarend Date: Wed, 12 Jul 2023 17:03:49 +0300 Subject: [PATCH] Fix CSP in dev mode (#1918) --- package.json | 2 +- src/server/index.tsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0fd3c670..f65c1173 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "scripts": { "analyze": "webpack --mode=none", "prebuild:dev": "yarn clean && node generate_translations.js", - "build:dev": "webpack --env LEMMY_UI_DISABLE_CSP=true --env COMMIT_HASH=$(git rev-parse --short HEAD) --mode=development", + "build:dev": "webpack --env COMMIT_HASH=$(git rev-parse --short HEAD) --mode=development", "prebuild:prod": "yarn clean && node generate_translations.js", "build:prod": "webpack --env COMMIT_HASH=$(git rev-parse --short HEAD) --mode=production", "clean": "yarn run rimraf dist", diff --git a/src/server/index.tsx b/src/server/index.tsx index 458d7f03..3b9352bf 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -29,7 +29,11 @@ server.use( ); server.use(setCacheControl); -if (!process.env["LEMMY_UI_DISABLE_CSP"] && !process.env["LEMMY_UI_DEBUG"]) { +if ( + !process.env["LEMMY_UI_DISABLE_CSP"] && + !process.env["LEMMY_UI_DEBUG"] && + process.env["NODE_ENV"] !== "development" +) { server.use(setDefaultCsp); }