Next.js Discord

Discord Forum

Fetch fails to https with self signed certificate

Answered
Sphecid wasp posted this in #help-forum
Open in Discord
Sphecid waspOP
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 Sphecid wasp
export NODE_TLS_REJECT_UNAUTHORIZED=0
View full answer

5 Replies

Sphecid waspOP
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?
Sphecid waspOP
I tried env. It shows warnings during build, but still gives error during start
Sphecid waspOP
It works
Sphecid waspOP
export NODE_TLS_REJECT_UNAUTHORIZED=0
Answer