DEV Community

loading...

Nuxt: Ignore SSL issues for axios proxy (Development only)

manizm profile image Muhammad Ali Naeemi ・1 min read

I just recently came across an issue, where me and my colleague were live sharing backend (in .net) and I was consuming it in Nuxt application but I was getting UNABLE_TO_VERIFY_LEAF_SIGNATURE and DEPTH_ZERO_SELF_SIGNED_CERT, SSL issues with nodejs and axios proxy.

All the ajax requests in (my) nuxt app goes through axios proxy plugin.

Usually this SSL issue happens because you are running or consuming a HTTPS server, but your machine cannot validate the SSL certificate.

After some research, I found an easy way to disable SSL checks (only for local development environment, please).
Here is what I am doing in my nuxt.config.js file.

(Here I am also assuming that you already have ENV environment variable setup)

{
// nuxt.config.js
...
    proxy: {
        '/api/': {
            target: process.env.MAIN_API_URL, // a url for your api
            secure: !process.env.ENV === 'development'
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Again, secure: false should be only setup when you are testing locally. Hope this saves you some hours of frustration :)

Discussion (0)

pic
Editor guide