anomalyco / anomalyco/opencode
Web client fails to fetch when URL contains credentials and throws BrowserAttachments context error
@Hona is already working on this.
Since Sep 15, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
When accessing the OpenCode web client with HTTP basic authentication credentials in the URL (for example http://username:password@127.0.0.1:<port>/), two issues occur:
fetch()throws:
TypeError: Failed to execute 'fetch' on 'Window': Request cannot be constructed from a URL that includes credentials
Because clearAuthToken() in packages/app/src/entry.tsx only handles ?auth_token= query parameters and uses a relative path in history.replaceState(), any credentials present in location.username and location.password remain in window.location. Under modern WHATWG Fetch specifications, browsers reject any request constructed from a URL with embedded credentials. Additionally, embedded credentials in the URL are not extracted into auth, causing requests to fail with 401.
- If a session or route is loaded where
BrowserAttachmentsProvideris not active (or outside desktop context),useBrowserAttachments()unconditionally throws:
Error: BrowserAttachments context must be used within a context provider
instead of falling back to a disabled/no-op attachment state on Web.
Steps to reproduce
- Run
OPENCODE_SERVER_PASSWORD=secret opencode serve(oropencode web). - Open
http://opencode:secret@127.0.0.1:4096/directly in Google Chrome or Safari. - Observe
TypeError: Failed to execute 'fetch' on 'Window'and/orError: BrowserAttachments context must be used within a context provider.
OpenCode version
v2.0.3
Operating System
macOS / Linux / Windows
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.