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.

ERR_TLS_CERT_ALTNAME_INVALID

See original GitHub issue

Expected behavior

I’m supposed to get the request via proxy

Actual behavior

I’m getting ALTNAME error

Setup

  • http-proxy-middleware: 0.17.4
  • server: express + 4.15.2
  • other relevant modules

proxy middleware configuration

function relayRequestHeaders(proxyReq, req) {
    Object.keys(req.headers).forEach(function (key) {
        proxyReq.setHeader(key, req.headers[key]);
    });
};

function relayResponseHeaders(proxyRes, req, res) {
    Object.keys(proxyRes.headers).forEach(function (key) {
        res.append(key, proxyRes.headers[key]);
    });
};

const options = {
	target: 'example.com',
	logLevel: 'debug',
	onProxyReq: relayRequestHeaders,
	onProxyRes: relayResponseHeaders
}

server mounting

var app = express();

app.use('/apps', proxy(options));
app.listen(3000);

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:8

github_iconTop GitHub Comments

47reactions
alexichepuracommented, Oct 24, 2018

Had same issue. Added changeOrigin to fix this and pathRewrite to fix 404

  const apiProxy = proxy('/api', {
    target: API_ENDPOINT,
    changeOrigin: true,
    pathRewrite: { '^/api': '' }, // remove leading /api to match real API urls
  })
0reactions
webunderconstructioncommented, Jan 4, 2021

A test https server I was trying to proxy to was using a self signed certificate, I found that by striping all the request headers seemed to allow it to successfully connect and return a response.

I changed the relayRequestHeaders function to this;

function relayRequestHeaders(proxyReq, req) {
  Object.keys(req.headers).forEach(function (key) {
    // strip all the request headers, as the receiving server is freaking out on one of them
    proxyReq.setHeader(key, '');
  });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

npm ERR! code ERR_TLS_CERT_ALTNAME_INVALID
An earlier outage involving a DNS misconfiguration has lead to some ISPs caching npmjs.com as missing, a workaround for this is to use...
Read more >
[ERR_TLS_CERT_ALTNAME_INVALID] #NodeJS · GitHub
ERR_TLS_CERT_ALTNAME_INVALID indicates self signed TLS error. Obsured by the following where xxxx.xxx.com can be a variety of host names.
Read more >
Getting the [ERR_TLS_CERT_ALRTNAME_INVALID] error ...
Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: Host: api.example.com. is not in the cert's ...
Read more >
Hostname/IP does not match certificate's altnames&quot ... - PTC
"Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames" is seen when creating a Connector that uses ...
Read more >
ERR_TLS_CERT_ALTNAME_IN...
ERR_TLS_CERT_ALTNAME_INVALID during deployment through pipeline. Hello,. Getting below error while deploying the changes to app service. ##[ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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