Next.js Discord

Discord Forum

Getting error Fetch failed, cause: unable to get local issuer certificate

Unanswered
୧ʕ•̀ᴥ•́ʔ୨ posted this in #help-forum
Open in Discord
Avatar
I am running next dev --experimental-https and can access the page locally via https://localhost, but the fetch still fails. If I put process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" in next.config.js is works, but this isn't recommended from what I've read.

Any ideas what else to try?

14 Replies

Avatar
you gotta need NODE_TLS_REJECT_UNAUTHORIZED = 0 if you don't have a signed cert for the server
Avatar
Isn't --experimental-https meant to resolve this?
It added a /certificates/ folder
I have localhost.pem and localhost-key.pem in it
Avatar
I think it just generate the cert for you
but it is not signed/trusted
Avatar
Hmm, seems like a pain to get it to work
Is it bad to run NODE_TLS_REJECT_UNAUTHORIZED = "0" in development?
Avatar
oh i just tried, and it is an signed cert
what do you get error from?
Avatar
It's an image, I have this in my next.config.js
remotePatterns: [ { protocol: "https", hostname: "cdn.sanity.io", port: "", pathname: "/**", }, ],
Avatar
remotePatterns: [
    {
        protocol: "https",
        hostname: "cdn.sanity.io"
    },
],

does this work?
Avatar
No :/ It works fine if I set NODE_TLS_REJECT_UNAUTHORIZED = "0"
Avatar
well I think its fine to have NODE_TLS_REJECT_UNAUTHORIZED in dev mode