Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

314
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!