Next.js Discord

Discord Forum

Fetch fails to https with self signed certificate

Answered
Large oak-apple gall posted this in #help-forum
Open in Discord
Large oak-apple gallOP
In current project I need to temporarily serve site from ip instead of domain name. Which means https is possible with self signed certificate (using caddy auto https). Which is not bad.
But it gives this error when trying to fetch something from /api
[cause]: [Error: unable to get local issuer certificate] {
  code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
}

Is there solution or workaround?
Answered by Large oak-apple gall
export NODE_TLS_REJECT_UNAUTHORIZED=0
View full answer

5 Replies

Large oak-apple gallOP
No, I saw it is for npm install, and my issue is with fetch, so I never looked into it. Which of answers do you mean? With npm command or with env variable?
Large oak-apple gallOP
I tried env. It shows warnings during build, but still gives error during start
Large oak-apple gallOP
It works
Large oak-apple gallOP
export NODE_TLS_REJECT_UNAUTHORIZED=0
Answer