[FEATURE] Respect the BROWSER environment variable
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
We use Claude inside a Linux Docker container. When we login, opening the browser fails, and we have to manually paste in the url and then paste back the key.
That's fine, and works, but it's annoying. /login -> copy -> paste -> auth -> copy -> paste
For other apps that use an OAuth2 flow we have automatic tooling that can forward the login url and pass back the key in Oauth2 contexts. It seems like the only thing preventing this from working in claude-code is that it doesn't seem to respect the BROWSER env parameter which is what tools like open xdg-open etc use to figure out which browser to open.
The usage of BROWSER to tell a cli where to send a browser request including an OAuth2 request is standard, and used by git credential manager for example.
In fact, when we asked you (claude-code) about making this work it suggested:
" File a feature request - This is a legitimate use case. You can report it at https://github.com/anthropics/claude-code/issues requesting that Claude Code respect the BROWSER environment variable for containerized/remote development scenarios."
So that's what I'm doing! Thank you for considering.
Proposed Solution
Simply respect the BROWSER= environmental variable when set, i.e., call the app/script set there to handle the start of the Oauth2 flow.
If claude-code is using xdg-open under the hood this may be as simple as just passing the BROWSER env variable when that process is spawned by node...
Alternative Solutions
_No response_
Priority
Low - Nice to have
Feature Category
Configuration and settings
Use Case Example
With this feature enabled and host/docker Oauth2 proxy like https://github.com/sam-mfb/oauth2-forwarder, you could simply:
- Start a dev docker container
- Launch claude
- Enter /login
- Login to your claude account and do Oauth on your host's browser
- Continuing working in claude in your dev container
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗