-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(wrangler): don't proxy localhost requests during dev #12516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest 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 finished @edmundhung's task —— View job Changeset ReviewReviewing changeset file(s) for this PR...
✅ All changesets look good The changeset
The changeset effectively communicates what was broken, how it's fixed, and important details about the new behavior. |
d54a982 to
e3adbd1
Compare
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: James Opstad <13586373+jamesopstad@users.noreply.github.com>
720903f to
88594ca
Compare
Co-authored-by: James Opstad <13586373+jamesopstad@users.noreply.github.com>
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
ProxyAgentwith undici'sEnvHttpProxyAgent, which natively supportsNO_PROXY. WhenNO_PROXYis not set, it defaults tolocalhost,127.0.0.1,::1, so local dev server requests are never proxied.The
NO_PROXYconfig 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.vite devwith a non existentHTTP_PROXY(e.g.http_proxy=http://127.0.0.1:11451 vite dev)TypeError: fetch failed)A picture of a cute animal (not mandatory, but encouraged)