๐ BUG: pages dev with https cannot proxy request (to https server)
See original GitHub issueWhat version of Wrangler
are you using?
2.1.6
What operating system are you using?
MacOS
Describe the Bug
Iโm unable to proxy to vite when using --local-protocol https step to reproduce:
npm create vite@latest my-vue-app -- --template vue-ts
cd my-vue-app
npm i -D wrangler
npx wrangler pages dev --local-protocol https -- npx vite --https
in vite.config.ts add:
server:{ https: {
key: fs.readFileSync('./localhost.internal.tld.key'),
cert: fs.readFileSync('./localhostinternal.tld.pem')
}}
or with an automatic self signed certificate (with @vitejs/plugin-basic-ssl plugin):
import mkcert from '@vitejs/plugin-basic-ssl'
โฆโฆโฆ
plugins: [
mkcert(),vue() ],
server: { https: true },
Open https://127.0.0.1:8788 On console:
๐ง 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose
Running npx vite...
Sleeping 5 seconds to allow proxy process to start before attempting to automatically determine port...
To skip, specify the proxy port with --proxy.
[proxy]:
VITE v3.1.3 ready in 354 ms
[proxy]: โ Local: http://127.0.0.1:5173/
โ Network: use --host to expose
Automatically determined the proxy port to be 5173.
No functions. Shimming...
โฒ [WARNING] Passing --inspect is unnecessary, now you can always connect to devtools.
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ [b] open a browser, [d] open Devtools, [c] clear console, [x] to exit โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Starting inspector on 0.0.0.0:9229 failed: address already in use
[pages:wrn] Service bindings are experimental. There may be breaking changes in the future.
[pages:inf] Generating new self-signed certificate...
[pages:inf] Updated `Request.cf` object cache!
[pages:inf] Worker reloaded! (322B)
[pages:inf] Listening on 0.0.0.0:8788
[pages:inf] - https://127.0.0.1:8788
[pages:inf] - https://192.168.2.42:8788
[pages:err] Error: Could not proxy request: TypeError: fetch failed
at file:///Users/--/my-vue-app/node_modules/wrangler/miniflare-dist/index.mjs:5995:27
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Fetcher.fetch (/Users/--/my-vue-app/node_modules/@miniflare/core/src/plugins/bindings.ts:130:17)
at Object.fetch (/Users/--/my-vue-app/node_modules/wrangler/templates/pages-shim.ts:6:20)
at EventTarget.[kDispatchFetch] (/Users/--/my-vue-app/node_modules/@miniflare/core/src/standards/event.ts:385:13)
at Server.<anonymous> (/Users/--/my-vue-app/node_modules/@miniflare/http-server/src/index.ts:298:20)
GET / 502 Bad Gateway (70.85ms)
On browser: [wrangler] Could not proxy request: TypeError: fetch failed
I tried to configure vite to listen to a https port with the same resule
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
React App Proxy Error: Could Not Proxy Request
I cloned the repo and did npm install in both the root folder and the client folder. When I enter npm run dev,...
Read more >Using the proxy | Guide | ArcGIS API for JavaScript 3.42
The proxy consists of server-side code that runs on your web server. Your browser based web application sends the request to the proxy...
Read more >Why you should use a proxy server with Create React App
Some examples of proxying requests in React applications are listed below. First is requesting HTTPS APIs in development ( https://localhost ).
Read more >Troubleshooting SSL - GitLab Docs
The echo command sends a null request to the server, causing it to close the connection ... ERROR: Not a certificate: /opt/gitlab/embedded/ssl/certs/FILE.
Read more >Troubleshooting - Wiki.js - requarks.io
Cause: You are most likely using a reverse proxy such as nginx or apache. Resolution: Increase your reverse proxy configuration for file uploads....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found a workaround I produced a certificate with:
signed by our subca internal.tld certificate I added an environment variable in my VsCode environment
"NODE_EXTRA_CA_CERTS":"${workspaceFolder}/subca.internal.tld.pem",
And finally it works !
So for using --local-protocol https to https server you must have a valid signed certificate witch it does not make sense. I think the Agent of undici.fetch must include
Agent({ connect: { rejectUnauthorized: false } })
Still same with 2.2.1
I updated my test repo for using my (worst/ugly/โฆ) workaround. only once issue:
next use as usual:
package.json