Skip to content

Commit 4cd16af

Browse files
committed
fix(pds): reflect requested CORS headers instead of a fixed allowlist
My previous commit hand-listed allowed headers (to get Authorization working), but that quietly dropped others browsers need (accept-language, x-bsky-topics, etc). Omitting allowHeaders lets Hono echo the requested headers back, matching the [reference atproto PDS](https://github.com/bluesky-social/atproto/blob/7f5c4ceb0b6872cb921ba9c2fab8c38614414f6c/packages/pds/src/index.ts#L171) and covering anything future clients send.
1 parent 6266817 commit 4cd16af

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

.changeset/cors-authorization-header.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
Be explicit with CORS headers so browser-based authenticated XRPC calls work (particularly PDS Moover).
66

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.
7+
The CORS middleware advertised `Access-Control-Allow-Headers: *`, but this didn't cover the `Authorization` header needed by tools like PDS Moover. As a result, authed cross-origin requests from web clients (eg. PDS Moover's `com.pdsmoover.backup.getRepoStatus`) were blocked at preflight. This is now resolved; all headers are reflected back, just like the Bluesky implementation.

packages/pds/src/index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,12 @@ app.use(
8484
cors({
8585
origin: "*",
8686
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
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-
],
87+
// Omit allowHeaders: Hono reflects the browser's
88+
// Access-Control-Request-Headers back, matching the reference
89+
// atproto PDS (`cors({ maxAge })`). This allows Authorization
90+
// (a `*` wildcard wouldn't), DPoP, atproto-proxy,
91+
// atproto-accept-labelers, accept-language, x-bsky-topics and
92+
// any future header automatically.
9793
exposeHeaders: ["Content-Type"],
9894
maxAge: 86400,
9995
}),

0 commit comments

Comments
 (0)