Skip to content

The open-source app everyone uses to manage agents at work

fix: trust PAPERCLIP_PUBLIC_URL in board mutation guard (#3731)

Jannes Stubbemannf460f744eff5
diff --git a/server/src/middleware/board-mutation-guard.ts b/server/src/middleware/board-mutation-guard.ts
index feff3b409a..96e2a46122 100644
--- a/server/src/middleware/board-mutation-guard.ts
+++ b/server/src/middleware/board-mutation-guard.ts
@@ -24,6 +24,12 @@ function trustedOriginsForRequest(req: Request) {
origins.add(`http://${host}`.toLowerCase());
origins.add(`https://${host}`.toLowerCase());
}
+ // Behind some reverse proxies the Host / X-Forwarded-Host header may
+ // not match the public URL (for example when TLS terminates at the
+ // edge and the inbound Host is an internal service name). Trust the
+ // explicitly-configured PAPERCLIP_PUBLIC_URL when it's set.
+ const publicUrl = parseOrigin(process.env.PAPERCLIP_PUBLIC_URL?.trim());
+ if (publicUrl) origins.add(publicUrl);
return origins;
}