Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

466
Visualizações
FetchError: unable to verify the first certificate, but I added rejectUnauthorized: false

I have a simple getServerSideProps() function that calls an external API but throws this error:

FetchError: request to https://nginx/api/items failed, reason: unable to verify the first certificate

The Node server does not trust my self-signed certificate.

So I found this Stack Overflow post to bypass that (I'm only using it in development):

How to configure axios to use SSL certificate?

So I added the rejectUnauthorized: false to my Axios call like so:

export async function getServerSideProps() {
const res = await fetch('https://nginx/api/items',
   { rejectUnauthorized: false,
     method: 'GET',
   }
)

const { data } = await res.json()
return { props: { data } }
}

But I still get the error.

Is there another way to make my self-signed certificate work with Next? I found some other solutions, but they are for Express, I don't know how to implement that for Node with Next.js

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The rejectUnautorized belongs in an HttpAgent:

const https = require('https');
const agent = new https.Agent({
  rejectUnauthorized: false
});
const res = await fetch('https://nginx/api/items', { 
     method: 'GET',
     agent
   }
);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda