Skip to content

Commit 6266817

Browse files
committed
fix(pds): allow Authorization header in CORS preflight
The CORS middleware advertised `Access-Control-Allow-Headers: *`, but `*` wildcard does not cover the `Authorization` header. Authenticated cross-origin XRPC calls from web clients (e.g. PDS Moover's getRepoStatus) were being blocked at preflight. Lists the allowed headers explicitly instead.
1 parent 0aec631 commit 6266817

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@getcirrus/pds": patch
3+
---
4+
5+
Be explicit with CORS headers so browser-based authenticated XRPC calls work (particularly PDS Moover).
6+
7+
The CORS middleware advertised `Access-Control-Allow-Headers: *`, but the Fetch spec calls out that `*` wildcard does not cover the `Authorization` header — browsers require it to be named explicitly. As a result, authed cross-origin requests from web clients (eg. PDS Moover's `com.pdsmoover.backup.getRepoStatus`) were blocked at preflight. As `*` can't be used with other headers, all allowed headers are now listed explicitly.

packages/pds/src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,16 @@ app.use(
8484
cors({
8585
origin: "*",
8686
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
87-
allowHeaders: ["*"],
87+
// `Authorization` must be listed explicitly: a `*` wildcard in
88+
// Access-Control-Allow-Headers doesn't cover `Authorization`,
89+
// so browsers block authed XRPC calls (e.g. PDS Moover).
90+
allowHeaders: [
91+
"Authorization",
92+
"Content-Type",
93+
"DPoP",
94+
"atproto-proxy",
95+
"atproto-accept-labelers",
96+
],
8897
exposeHeaders: ["Content-Type"],
8998
maxAge: 86400,
9099
}),

0 commit comments

Comments
 (0)