Add custom Host header to supertest request

Viewed 516

I have to following request that works when I use curl:

curl --location --request GET 'https://my-domain.net/manager' --header 'Authorization: Basic xyz=' --header 'Host: my-host' --header 'Trace-Id: my-trace'

when I try to implement it in supertest (to create a 2e2 test) it fails with:

Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: Host: my-host. is not in the cert's altnames: DNS:my-domain.net

It seems like supertest won't accept the custom Host header.

let request = supertest('https://my-domain.net');
const res = await request
  .get(/manager)
  .set(headers)
  .expect(200);

Is there a way around it?

0 Answers
Related