Can't proxy to a server that uses a self-signed certificate #49546
Replies: 12 comments 7 replies
-
Converted to discussions as this doesn't seem related to Next.js, we use http-proxy. |
Beta Was this translation helpful? Give feedback.
-
Are there any other suggestions on how we get around this issue developing locally? |
Beta Was this translation helpful? Give feedback.
-
Can we add a secure option? In development, it is very common to use a self-signed certificate. |
Beta Was this translation helpful? Give feedback.
-
+1 for secure option with express middleware something like this is doable:
|
Beta Was this translation helpful? Give feedback.
-
For anyone wondering, the only workaround I found is using ngrok. It's absurd that I have to use a third-party tool to work around the fact that there's no options for nextjs dev server to ignore certificate validation |
Beta Was this translation helpful? Give feedback.
-
Another option is to setup a local proxy on arbitrary port:
Something like that:
|
Beta Was this translation helpful? Give feedback.
-
To keep using nextjs server I set up middleware in
|
Beta Was this translation helpful? Give feedback.
-
Pretty absurd that this is still not fixed.. |
Beta Was this translation helpful? Give feedback.
-
any updates ? |
Beta Was this translation helpful? Give feedback.
-
Vite proxies allow redirecting to sites with self-signed certficates: see https://vite.dev/config/server-options#server-proxy. (Note that server.proxy extends http-proxy which has a "secure: false" option: https://github.com/http-party/node-http-proxy#options). |
Beta Was this translation helpful? Give feedback.
-
Hello, I want to ask is my issue the same #74187 ? Because my usecase would be to ignore tls on the server-side fetch (not middleware), direct call to my BE api layer. |
Beta Was this translation helpful? Give feedback.
-
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 Binaries: Node: 18.15.0 npm: 9.5.0 Yarn: 1.22.19 pnpm: 7.30.0 Relevant packages: next: 13.3.1-canary.2 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue
https://github.com/seyoon20087/next-proxy-self-signed-certificate-error-reproduction
To Reproduce
Note: I tested this on Gitpod but the following steps might work on other systems, as long as the host OS is based on Unix (i.e. not Windows without a WSL environment).
yarn install
yarn dev
http://localhost:3000/c
to see whether errors are being observed in the/c
routeNODE_TLS_REJECT_UNAUTHORIZED
environment variable to0
Describe the Bug
Maybe relevant to #45743 ; however that was closed already, so I am recreating an issue with a reproduction.
Some developers want to connect to a server that uses a self-signed certificate (only in dev-mode). However, this doesn't work even if
NODE_TLS_REJECT_UNAUTHORIZED
is set to0
.If I attempt to do that, whether
NODE_TLS_REJECT_UNAUTHORIZED
is set to0
or not, it ends up with the following:I'm not sure if this is the intentional behavior on Next.js itself.
Expected Behavior
I expected the error above to NOT happen (and Node.js would allow to be connected to that server).
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Beta Was this translation helpful? Give feedback.
All reactions