Proxy error: Could not proxy request (DEPTH_ZERO_SELF_SIGNED_CERT)
See original GitHub issueI’ve setup a Node.js server with my React app that needs to connect to external APIs via HTTPS.
So in development I’ve installed a self signed cert.
openssl genrsa -out localhost.key 2048
openssl req -new -x509 -key localhost.key -out localhost.cert -days 3650 -subj /CN=localhost
A snippet from my Node.js express setup looks like so
sslOptions = {
key: fs.readFileSync('./config/localhost.key'),
cert: fs.readFileSync('./config/localhost.cert'),
requestCert: false,
rejectUnauthorized: false
};
https.createServer(sslOptions, app).listen(PORT, () => {
console.log(serverStartMessage);
});
In my package.json for the create-react-app part of the overall app I’ve added this snippet:
"proxy": {
"/auth/google": {
"target": "https://localhost:8008"
},
"/api/*": {
"target": "https://localhost:8008"
}
},
I had this working over HTTP, and then Google required my callbacks in console.developers.google.com to all be HTTPS. And so I refactored some of the code to ensure everything was sent over HTTPS. I have the full app working in production (as I have a properly signed and setup cert on the production server), but in development I’m struggling to get create-react-app proxying to the dev server.
So now when I goto a URL like https://localhost:3000/api/logout
I get
Proxy error: Could not proxy request /api/logout from localhost:3000 to https://localhost:8008 (DEPTH_ZERO_SELF_SIGNED_CERT).
How do I get around this to get it working with a self signed cert for local development?
Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top GitHub Comments
The solution is not working for me, any other solutions?
Adding
"secure": false
to my package.json proxy config solved this problem for me. Thanks @telemmaite !package.json