Dough Git

commit

Fix CSP

commit
0ff0406f4e9fca8578d288c0810e8ba7bbd2bb55
author
Clove Twilight <[email protected]>
date
2026-09-01 17:40

diff --git a/src/server.ts b/src/server.ts
index 9641965..351dfee 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -112,7 +112,11 @@ app.use("*", async (c, next) => {
   if (GIT_RPC.test(c.req.path) || c.req.path.endsWith("/info/refs")) return;
   c.header("Content-Security-Policy", CSP);
   c.header("X-Content-Type-Options", "nosniff");
-  c.header("Referrer-Policy", "no-referrer");
+  // Not "no-referrer": under that policy a browser sends `Origin: null` on
+  // same-origin form POSTs (Fetch, "append a request Origin header"), and no
+  // Referer to fall back on, so the CSRF check below rejects every form on the
+  // site. "same-origin" leaks nothing outward and keeps both headers intact.
+  c.header("Referrer-Policy", "same-origin");
   c.header("X-Frame-Options", "DENY");
   if (SITE_ORIGIN.startsWith("https://")) {
     c.header("Strict-Transport-Security", "max-age=31536000; includeSubDomains");