Skip to content

Claude Code ignores ANTHROPIC_BASE_URL — login screen shown despite proxy running correctly #2

@hariomkhonde108

Description

@hariomkhonde108

Environment

  • OS: Ubuntu Linux
  • Claude Code version: 1.0.3
  • Node.js version: 20.x
  • Setup: claude-code-copilot proxy (no Docker)

Problem

Following the README exactly, even with the proxy running correctly and env vars
set, Claude Code 1.0.3 always shows the login/OAuth screen and never connects
through the proxy.

The proxy was confirmed working:

  • curl http://localhost:18080/v1/models returned models correctly
  • echo $ANTHROPIC_BASE_URLhttp://localhost:18080
  • echo $ANTHROPIC_API_KEYcopilot-proxy
  • ~/.claude/credentials.json was correctly set

Despite all of this, Claude Code kept triggering the OAuth login flow and
ignoring ANTHROPIC_BASE_URL entirely.

Root Cause

Claude Code 1.0.3 introduced an onboarding gate that runs before it reads
any environment variables or credentials file. Until hasCompletedOnboarding
is set in ~/.claude.json, it bypasses all custom config and forces the login
screen.

Additionally, Claude Code 1.0.3 changed the environment variable name from
ANTHROPIC_API_KEY to ANTHROPIC_AUTH_TOKEN.

Fix

1. Mark onboarding as complete:

echo '{"hasCompletedOnboarding": true}' > ~/.claude.json

2. Use the correct env var name:

export ANTHROPIC_AUTH_TOKEN=copilot-proxy
export ANTHROPIC_BASE_URL=http://localhost:18080

3. Disable background traffic to Anthropic's real servers:

export DISABLE_NON_ESSENTIAL_MODEL_CALLS=1
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1

4. Launch:

ANTHROPIC_AUTH_TOKEN=copilot-proxy \
ANTHROPIC_BASE_URL=http://localhost:18080 \
DISABLE_NON_ESSENTIAL_MODEL_CALLS=1 \
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
claude

## Suggested Fix for This Repo
The `scripts/launch.sh` and README should be updated to:

1. Auto-write `~/.claude.json` with `hasCompletedOnboarding: true` before 
   launching claude
2. Use `ANTHROPIC_AUTH_TOKEN` instead of (or in addition to) `ANTHROPIC_API_KEY`
3. Include `DISABLE_NON_ESSENTIAL_MODEL_CALLS` and 
   `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` in the launch command
4. Add a note in the README Troubleshooting section about this for 
   Claude Code 1.0.3+

## Suggested launch.sh patch
Add this block before the final `claude "$@"` line in `scripts/launch.sh`:
```bash
# Ensure onboarding is marked complete so Claude Code doesn't show login screen
CLAUDE_JSON="$HOME/.claude.json"
if [ ! -f "$CLAUDE_JSON" ] || ! grep -q "hasCompletedOnboarding" "$CLAUDE_JSON"; then
    echo '{"hasCompletedOnboarding": true}' > "$CLAUDE_JSON"
    echo "✓ Marked Claude Code onboarding as complete"
fi

ANTHROPIC_BASE_URL="http://localhost:$PORT" \
ANTHROPIC_AUTH_TOKEN="copilot-proxy" \
ANTHROPIC_API_KEY="copilot-proxy" \
DISABLE_NON_ESSENTIAL_MODEL_CALLS=1 \
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
claude "$@"
```

That covers the bug, root cause, fix, and a concrete patch for the maintainer to apply. Should be a solid and useful issue report! this msg is written by calude it self

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions