{"version":"2.1.331","anchor":"new-claude-code-disable-redirect-check-env-var-and-redirectr","canonical_anchor":"new-claude-code-disable-redirect-check-env-var-and-redirectr","heading":"Claude Code now refuses unexpected redirects of model API requests","tier":"use","area":"Auth","scope":"both","heads_up":true,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.331\/e\/new-claude-code-disable-redirect-check-env-var-and-redirectr","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.331","markdown":"### Claude Code now refuses unexpected redirects of model API requests\n\nRedirected model API requests are now refused with a clearer error, and CLAUDE_CODE_DISABLE_REDIRECT_CHECK turns the new check off\n\n**Unclear.** What the redirect check does, and whether `CLAUDE_CODE_DISABLE_REDIRECT_CHECK` turns it off, is not stated.\n\n**What**\n\nA redirect is a server's reply telling the program to send its request somewhere else. Networks that ask you to sign in first, such as hotel or office Wi-Fi, and some proxies redirect traffic this way. Claude Code now checks for this on the requests it sends to the model:\n\n- Model API requests that send data (POST requests) and set no redirect option of their own are now retried with `redirect: error`. An unexpected redirect goes to a handler that either follows it or stops with `Claude Code refused a redirect of this request`. Before, redirected responses were only logged after the fact and never blocked.\n\n- A refused redirect now has its own error code, `RedirectRefused`, and its own message: `Unable to connect to API: sign in to network or proxy. The request was redirected`. The message then asks you to have your network administrator allow api.anthropic.com. Before, this case fell through to the generic `Unable to connect to API` message.\n\n- The new environment variable `CLAUDE_CODE_DISABLE_REDIRECT_CHECK` turns the check off. An environment variable is a named value set in your shell before Claude Code starts. Only the environment Claude Code starts with, your own settings or managed settings (settings an administrator sets for an organisation) may set it, so Claude itself cannot. It joins the same list of names as `AWS_ENDPOINT_URL_STS` and `CLAUDE_CODE_DISABLE_EARLY_KEY_GUARD`.\n\n- The check that decides whether an error is a sign-in problem now also requires an HTTP 401 status, the server's \"not authorised\" reply.\n\n**Why**\n\nA redirect could send model requests, along with your credentials, to a different server. Requests are now stopped instead. If you are behind a sign-in page or proxy, the error now tells you what to do. If the check gets in the way on your network, you can set `CLAUDE_CODE_DISABLE_REDIRECT_CHECK`.\n\n- Area: Auth\n- Names: `CLAUDE_CODE_DISABLE_REDIRECT_CHECK`\n- Tier: Use it now\n- Useful: 5\/5\n- Signal: 3\/5\n- Scope: both\n- Heads-up: yes"}