question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proxy error: Could not proxy request (DEPTH_ZERO_SELF_SIGNED_CERT)

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

37reactions
andrewlamywcommented, Apr 25, 2018

The solution is not working for me, any other solutions?

14reactions
danielmahoncommented, Mar 14, 2018

Adding "secure": false to my package.json proxy config solved this problem for me. Thanks @telemmaite !

package.json

...
"proxy": {
    "/api": {
      "target": "https://localhost:5002",
      "secure": false
    }
  },
...
Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Proxy error: Could not proxy request ... - Stack Overflow
Proxy error : Could not proxy request (DEPTH_ZERO_SELF_SIGNED_CERT) · You created https server with the self-signed certificate ./config/localhost ...
Read more >
Developers - Proxy error: Could not proxy request ...
I'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...
Read more >
Proxy request for local edge without verified cert - IoT
For local testing, i start the server proxy to my local edge with domain myown.iot.com. but fail to login, below is the error...
Read more >
Could not proxy request [route] from localhost:3000 to ... - Reddit
json as he instructed and npm installed again, and restarted terminal and even computer. Any tips? This error is very general and all...
Read more >
How to Resolve Certificate Errors in a NodeJS App with SSL ...
In this case, HTTPS is not required if the App does not need to call other ... the showcerts command may not work...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found