From 5d4edf555e4014ee5a4d384230e87ed06a1aa8fa Mon Sep 17 00:00:00 2001
From: Sander Saarend <sander@saarend.com>
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 5e3535b..fdc1dfd 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 458d7f0..3b9352b 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);
 }
 
-- 
2.44.1