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

315
Visualizações
Self signed certificate error when fetching API locally

I have a simple .NET Core WebAPI with no authentication. I added Cors with default policy. I have no problem connecting and fetching data from my React website or Postman (everything runs locally on my machine). Now I'm trying to fetch data from that API in super simple node application and I'm getting this error:

file:///Users/aw/Projects/TestNodeApp/node_modules/node-fetch/src/index.js:94
            reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, 'system', error));
                   ^

FetchError: request to https://localhost:5001/api/teams failed, reason: self signed certificate
    at ClientRequest.<anonymous> (file:///Users/aw/Projects/TestNodeApp/node_modules/node-fetch/src/index.js:94:11)
    at ClientRequest.emit (node:events:394:28)
    at TLSSocket.socketErrorListener (node:_http_client:447:9)
    at TLSSocket.emit (node:events:394:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'DEPTH_ZERO_SELF_SIGNED_CERT',
  code: 'DEPTH_ZERO_SELF_SIGNED_CERT',
  erroredSysCall: undefined
}

This is my whole node application:

import fetch from 'node-fetch';

async function fetchTeams() {
  const response = await fetch('https://localhost:5001/api/teams', { method: 'GET' });
  const data = await response.json();
  return data;
}

(async () => {
  console.log('Process started');
  const teams = await fetchTeams();
  console.log(teams);
})().finally(() => {
  console.log('Process finished');
});

What does it mean? What Am I missing?

Btw. It works fine, when I'm fetching Github API, like this:

async function fetchGithub() {
  const response = await fetch('https://api.github.com/users/Microsoft');
  const data = await response.json();
  return data;
}

So I assume, something is missing in the API. Something that my React website doesn't need, that node app needs.

Thanks for help!

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

0

Try trusting the self signed certificate with dotnet dev-certs

dotnet dev-certs https --trust

For more details please visit this documentation page.

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