Ask Your Question
1

How to resolve the "UNABLE_TO_VERIFY_LEAF_SIGNATURE" error when using Webpack DevServer to proxy an HTTPS resource?

asked 2023-06-03 23:16:50 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-03 23:20:02 +0000

bukephalos gravatar image

The "UNABLETOVERIFYLEAFSIGNATURE" error occurs when the SSL certificate of the HTTPS resource being proxied by Webpack DevServer cannot be verified.

To resolve this error, you can either:

  1. Disable SSL verification by adding the following line to the DevServer configuration:
proxy: {
  '/api': {
    target: 'https://example.com',
    secure: false
  }
}

Note that disabling SSL verification is not recommended for production use.

  1. Install the SSL certificate on your local machine and configure DevServer to trust it. To do this, follow these steps:
  • Obtain the SSL certificate from the HTTPS resource and save it to a file (e.g. example.crt).
  • Add the following line to your DevServer configuration:
proxy: {
  '/api': {
    target: 'https://example.com',
    secure: true,
    ssl: {
      key: fs.readFileSync('example.crt'),
      ca: fs.readFileSync('example.crt'),
      cert: fs.readFileSync('example.crt')
    }
  }
}

Note that this method will only work if the SSL certificate is issued by a trusted Certificate Authority.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-03 23:16:50 +0000

Seen: 10 times

Last updated: Jun 03 '23