You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failing to authenticate into web UI when username or password is set #9066
I set the environment variables OPENCODE_SERVER_USERNAME and OPENCODE_SERVER_PASSWORD, and then started a web UI using the opencode web command. However, when I open the server URL on browser, the authentication dialog keeps opening up even when I put correct username and password.
The server logs just say failed, and the subsequent run of opencode fails with an error saying Unauthorized.
If I unset the environment variables, opencode works again.
Plugins
No response
OpenCode version
1.1.21
Steps to reproduce
Set OPENCODE_SERVER_USERNAME and OPENCODE_SERVER_PASSWORD environment variables
Run opencode web --> cannot authenticate with the correct username and password
Run opencode --> fails with an error Unauthorized
Unset OPENCODE_SERVER_USERNAME and OPENCODE_SERVER_PASSWORD
opencode works again
Screenshot and/or share link
Operating System
macOS 26.3
Terminal
Ghostty
Reacted by Morgan Marshall, Alvaro and Tim Speedle
All three issues relate to authentication failures when OPENCODE_SERVER_PASSWORD environment variable is set, which appears to be a broader problem with how password-protected servers handle client authentication.
Feel free to ignore if your specific case differs from these.
This issue is now fixed by PR #9095, which completes the authentication fix started in PR #8179. The new PR addresses the HTTP server authentication path when TUI and server are started alongside with a password.
Hitting this on 1.4.0 with opencode serve --hostname 0.0.0.0 + browser access. TUI works fine (env vars), but the web UI's JS client doesn't attach credentials to its fetch calls — every API request after page load gets 401. Happy to test any fix.
Activity
github-actions commentedon Jan 17, 2026
This issue might be a duplicate of existing issues. Please check:
All three issues relate to authentication failures when OPENCODE_SERVER_PASSWORD environment variable is set, which appears to be a broader problem with how password-protected servers handle client authentication.
Feel free to ignore if your specific case differs from these.
LeonMueller-OneAndOnly commentedon Jan 17, 2026
This issue is now fixed by PR #9095, which completes the authentication fix started in PR #8179. The new PR addresses the HTTP server authentication path when TUI and server are started alongside with a password.
github-actions commentedon Mar 27, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.
cristoslc commentedon Apr 16, 2026
Hitting this on 1.4.0 with
opencode serve --hostname 0.0.0.0+ browser access. TUI works fine (env vars), but the web UI's JS client doesn't attach credentials to its fetch calls — every API request after page load gets 401. Happy to test any fix.