fix(desktop): inject Authorization header into match API requests via session.webRequest#3338
Open
ruanjf wants to merge 4 commits into
Open
fix(desktop): inject Authorization header into match API requests via session.webRequest#3338ruanjf wants to merge 4 commits into
ruanjf wants to merge 4 commits into
Conversation
…ession.webRequest <img> tags, iframes, and other non-fetch browser requests bypass the API client and carry no Authorization header. The server's static file redirect endpoint (GetStaticFileRedirect) requires either the Authorization header or the multica_auth cookie — neither of which Electron sets automatically — so authenticated images returned 401 and failed to display. Fix: register a combined onBeforeSendHeaders handler on the renderer session that injects `Authorization: Bearer <token>` for every request whose URL starts with the configured API base URL. The token is kept in sync in the main process via two new IPC channels (auth:set-token / auth:clear-token) called by the renderer on login and logout respectively. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
…bRequest Extract applyAuthRequestHeaders into a standalone module and cover it with 12 unit tests: Authorization injection for API requests, no-op when token or base URL is absent, no override of an existing header, no mutation of the input object, and Origin stripping for WebSocket upgrades. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
|
@ruanjiefeng is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
client and carry no Authorization header. The server's static file redirect
endpoint (GetStaticFileRedirect) requires either the Authorization header or
the multica_auth cookie — neither of which Electron sets automatically —
so authenticated images returned 401 and failed to display.
Fix: register a combined onBeforeSendHeaders handler on the renderer session
that injects
Authorization: Bearer <token>for every request whose URLstarts with the configured API base URL. The token is kept in sync in the
main process via two new IPC channels (auth:set-token / auth:clear-token)
called by the renderer on login and logout respectively.
Related Issue
Closes #
Type of Change
Changes Made
How to Test
Checklist
apps/web/features/landing/i18n/) and relevant docs (apps/docs/content/docs/)apps/docs/content/docs/developers/conventions.zh.mdx(terminology, mixed-rule fortask/issue/skill)AI Disclosure
AI tool used:
Prompt / approach:
Screenshots (optional)