Skip to content

Conversation

@edmundhung
Copy link
Member

@edmundhung edmundhung commented Feb 10, 2026

Fixes #8906.

It looks like wrangler's proxy setup bleeds into miniflare's inspector proxy and should skip proxying requests to localhost. I considered scoping the proxy setup to the wrangler CLI only , but the Vite plugin also needs it for remote binding API calls.

This fix replaces ProxyAgent with undici's EnvHttpProxyAgent, which natively supports NO_PROXY. When NO_PROXY is not set, it defaults to localhost,127.0.0.1,::1, so local dev server requests are never proxied.

The NO_PROXY config only applies to the request destination, not the proxy server address. So a proxy running on localhost (e.g., HTTP_PROXY=http://127.0.0.1:11451) still works for outbound API calls.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
      1. Run vite dev with a non existent HTTP_PROXY (e.g. http_proxy=http://127.0.0.1:11451 vite dev)
      2. See if you can reproduce the same error (i.e. TypeError: fetch failed)
      3. Update vite plugin to the pre-release version and try again
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bugfix

A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: 88594ca

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@claude
Copy link
Contributor

claude bot commented Feb 10, 2026

Claude finished @edmundhung's task —— View job


Changeset Review

Reviewing changeset file(s) for this PR...

  • Read changeset guidelines
  • Review changeset file
  • Validate against criteria
  • Provide feedback

All changesets look good

The changeset .changeset/fix-proxy-localhost.md is well-written and follows all guidelines:

  • Version Type: patch is correct for a bug fix
  • Changelog Quality: Clear, detailed description with proper context about the problem and solution
  • Markdown Headers: No h1/h2/h3 headers used
  • Format: Follows the recommended TITLE + BODY structure with imperative title
  • Content: Explains both the bug and the fix, includes technical details about EnvHttpProxyAgent and NO_PROXY behavior

The changeset effectively communicates what was broken, how it's fixed, and important details about the new behavior.

@edmundhung edmundhung force-pushed the edmundhung/fix-proxy-localhost branch from d54a982 to e3adbd1 Compare February 10, 2026 17:37
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 10, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12516

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12516

miniflare

npm i https://pkg.pr.new/miniflare@12516

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12516

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12516

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12516

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12516

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12516

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12516

wrangler

npm i https://pkg.pr.new/wrangler@12516

commit: 88594ca

@edmundhung edmundhung marked this pull request as ready for review February 11, 2026 11:10
@edmundhung edmundhung requested a review from a team as a code owner February 11, 2026 11:10
@edmundhung edmundhung changed the title fix(wrangler): support NO_PROXY environment variable fix(wrangler): don't proxy localhost requests during dev Feb 11, 2026
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@jamesopstad
Copy link
Contributor

jamesopstad commented Feb 11, 2026

Does this mean that proxy environment variables now work, or just that they don't crash?

@edmundhung
Copy link
Member Author

Does this mean that proxy environment variables now work, or just that they don't crash?

It should work. Just skip the proxy when a request is made against localhost.

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Feb 11, 2026
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

edmundhung and others added 2 commits February 11, 2026 13:13
Co-authored-by: James Opstad <13586373+jamesopstad@users.noreply.github.com>
@edmundhung edmundhung force-pushed the edmundhung/fix-proxy-localhost branch from 720903f to 88594ca Compare February 11, 2026 13:13
@edmundhung edmundhung merged commit 84252b7 into main Feb 11, 2026
39 of 40 checks passed
@edmundhung edmundhung deleted the edmundhung/fix-proxy-localhost branch February 11, 2026 14:20
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Feb 11, 2026
NuroDev pushed a commit that referenced this pull request Feb 11, 2026
Co-authored-by: James Opstad <13586373+jamesopstad@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Cannot start Vite dev server with proxy environment variables

2 participants