Don't overwrite Authorization HTTP header when no token is saved
authorCode-Otto <redacted>
Wed, 26 Jun 2024 21:20:26 +0000 (23:20 +0200)
committerCode-Otto <redacted>
Wed, 26 Jun 2024 21:20:26 +0000 (23:20 +0200)
This fixes setups where Flatnotes runs behind a proxy doing authentication
on its own

client/api.js

index 4657f9809e3468de62ca6ba2a55d0ba69d4cae62..46e3dcadfb174e5b3827ff800181c008468d05e0 100644 (file)
@@ -14,7 +14,9 @@ api.interceptors.request.use(
   function (config) {
     if (config.url !== "api/token") {
       const token = getStoredToken();
-      config.headers.Authorization = `Bearer ${token}`;
+      if (token) {
+        config.headers.Authorization = `Bearer ${token}`;
+      }
     }
     return config;
   },
git clone https://git.99rst.org/PROJECT