cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.69k stars 702 forks source link

🐛 BUG: Error with wrangler dev and HTTPS localhost sub-requests #5774

Open daniel-revell opened 6 months ago

daniel-revell commented 6 months ago

Which Cloudflare product(s) does this pertain to?

Miniflare

What version(s) of the tool(s) are you using?

wrangler 3.53.1

What version of Node are you using?

v21.1.0

What operating system and version are you using?

Mac Somona 14.4.1

Describe the Bug

Observed behavior

Sub-request to https://localhost result in error.

Expected behavior

HTTP requests work, would expect HTTPS requests to also work. Or a documented way to turn off HTTPS validation.

Steps to reproduce

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

[wrangler:inf] Ready on http://localhost:8787 ✘ [ERROR] WARNING: known issue with fetch() requests to custom HTTPS ports in published Workers:

✘ [ERROR] Uncaught (async) Error: internal error

[wrangler:err] Error: internal error at async passThroughHandler (file:///Users/daniel/Projects/api-worker/src/handlers/pass-through.handler.ts:13:10) at async Object.handle (file:///Users/daniel/Projects/api-worker/node_modules/itty-router/Router.js:1:614) at async Object.fetch (file:///Users/daniel/Projects/api-worker/src/index.ts:241:12) at async jsonError (file:///Users/daniel/Projects/api-worker/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10) at async drainBody (file:///Users/daniel/Projects/api-worker/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10) [wrangler:inf] POST /users/v1/tokens 500 Internal Server Error (99ms)

penalosa commented 3 months ago

To clarify, does your server running on localhost:5000 work with https://? (i.e. what happens when you open https://localhost:5000/ in a browser?)

vivaladan commented 3 months ago

Yes, I have a local ASP.NET web server running. The IDE installs a local development certificate to the machine upon first run so the browser is then fine with the self-signed certificate on any port. https://localhost:5000 displays the index page and all the JSON endpoints at /api/... work fine. Miniflare doesn't like it though, whether it's the port or certificate I don't know.

michaellzc commented 3 weeks ago

We ran into the same problem, and here's a minimal example to reproduce the problem locally. https://github.com/michaellzc/cf-workers-broken-local-https