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

does this work?
Avatar
୧ʕ•̀ᴥ•́ʔ୨OP
No :/ It works fine if I set NODE_TLS_REJECT_UNAUTHORIZED = "0"
Avatar
Ray
well I think its fine to have NODE_TLS_REJECT_UNAUTHORIZED in dev mode