Firefox treats an extension page's fetch to a host-permission origin as same-origin, so it attached the target origin's cookies to every request from the shared HTTP service. OpenRouter's /analytics/query runs Clerk auth whenever a session cookie is present and read the management key in the Authorization header as a session JWT, answering 403 ("Invalid JWT form"). Cookie-less requests (e.g. curl) use OpenRouter's API-key auth path and returned 200, which is why "Load keys" worked while the dashboard spend total failed.
The fix defaults the shared fetch to credentials: "omit" so extension requests never carry the target origin's cookies and authenticate purely via headers. It stays overridable per call, and every current consumer (site-icons, bitcoin, notifications, openrouter) authenticates with headers or hits public APIs.
classifyError() now also surfaces OpenRouter's own error.message for failed requests, falling back to the existing status summaries, so future auth or permission failures stay diagnosable instead of showing a generic "Management key required".
Adds unit tests for the credentials default and override, and for the surfaced API message.
Firefox treats an extension page's `fetch` to a host-permission origin as same-origin, so it attached the target origin's cookies to every request from the shared HTTP service. OpenRouter's `/analytics/query` runs Clerk auth whenever a session cookie is present and read the management key in the `Authorization` header as a session JWT, answering `403` ("Invalid JWT form"). Cookie-less requests (e.g. `curl`) use OpenRouter's API-key auth path and returned `200`, which is why "Load keys" worked while the dashboard spend total failed.
The fix defaults the shared fetch to `credentials: "omit"` so extension requests never carry the target origin's cookies and authenticate purely via headers. It stays overridable per call, and every current consumer (site-icons, bitcoin, notifications, openrouter) authenticates with headers or hits public APIs.
`classifyError()` now also surfaces OpenRouter's own `error.message` for failed requests, falling back to the existing status summaries, so future auth or permission failures stay diagnosable instead of showing a generic "Management key required".
Adds unit tests for the credentials default and override, and for the surfaced API message.
Extension pages with host permissions are treated as same-origin, so the
target origin's cookies rode along on every request. OpenRouter's
Clerk-protected analytics endpoint then tried to read the management key in
the Authorization header as a session JWT and answered 403, breaking the
spend total on the dashboard.
Default the shared fetch to credentials "omit" (still overridable per call),
and surface OpenRouter's own error message for failed requests instead of a
generic status summary.
raucao
added the bug label 2026-11-16 08:25:33 +00:00
raucao
merged commit 865402938a into master2026-11-16 08:25:55 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Firefox treats an extension page's
fetchto a host-permission origin as same-origin, so it attached the target origin's cookies to every request from the shared HTTP service. OpenRouter's/analytics/queryruns Clerk auth whenever a session cookie is present and read the management key in theAuthorizationheader as a session JWT, answering403("Invalid JWT form"). Cookie-less requests (e.g.curl) use OpenRouter's API-key auth path and returned200, which is why "Load keys" worked while the dashboard spend total failed.The fix defaults the shared fetch to
credentials: "omit"so extension requests never carry the target origin's cookies and authenticate purely via headers. It stays overridable per call, and every current consumer (site-icons, bitcoin, notifications, openrouter) authenticates with headers or hits public APIs.classifyError()now also surfaces OpenRouter's ownerror.messagefor failed requests, falling back to the existing status summaries, so future auth or permission failures stay diagnosable instead of showing a generic "Management key required".Adds unit tests for the credentials default and override, and for the surfaced API message.