Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs - ERR_TLS_CERT_ALTNAME_INVALID

I have called this function below:

export async function getStaticProps() {
  const res = await fetch("https://links.papareact.com/pyp");
  const exploreData = await res.json();

  return {
    props: {
      exploreData,
    },
  };
}

And it is showing the error below. How do I solve this issue?

enter image description here

Server Error
FetchError: request to https://jsonkeeper.com/b/4G1G failed, reason: Hostname/IP does not match certificate's altnames: Host: jsonkeeper.com. is not in the cert's altnames: DNS:www.jsonkeeper.com
This error happened while generating the page. Any console logs will be displayed in the terminal window.

Call Stack
ClientRequest.<anonymous>
file:///P:/Work/Web%20Development/airbnb-clone/node_modules/next/dist/compiled/node-fetch/index.js (1:65756)
ClientRequest.emit
node:events (527:28)
TLSSocket.socketErrorListener
node:_http_client (454:9)
TLSSocket.emit
node:events (527:28)
emitErrorNT
node:internal/streams/destroy (157:8)
emitErrorCloseNT
node:internal/streams/destroy (122:3)
processTicksAndRejections
node:internal/process/task_queues (83:21)`your text`

I was trying to call an API but its showing

type: 'system',
  errno: 'ERR_TLS_CERT_ALTNAME_INVALID',
  code: 'ERR_TLS_CERT_ALTNAME_INVALID',

I have installed mkcert but the problem was not solved.

like image 917
Jaid Chowdhury Avatar asked Oct 23 '25 16:10

Jaid Chowdhury


1 Answers

You just need to add www to the jsonkeeper link

export async function getStaticProps() {
  const res = await fetch('https://www.jsonkeeper.com/b/4G1G');
  const exploreData = await res.json();

  return {
    props: {
      exploreData,
    },
  };
}
like image 161
Adila Avatar answered Oct 26 '25 06:10

Adila