JavaScript Answers

How to fix Node.js Hostname/IP doesn’t match certificate’s altnames?

Spread the love

To fix Node.js Hostname/IP doesn’t match certificate’s altnames, we proxy to the target URL.

For instance, we write

const proxy = httpProxy.createProxyServer();

proxy.web(req, res, {
  changeOrigin: true,
  target: "",

to call proxy.web to proxy requests to

If we use HTTPS, we should include the key and certificate by writing

    ssl: {
      key: fs.readFileSync("valid-ssl-key.pem", "utf8"),
      cert: fs.readFileSync("valid-ssl-cert.pem", "utf8"),
    target: "",
    secure: true,

to call add call createServer with the key and cert set.

And we proxy requests to

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *