I am using a dependency that requires me to have HTTPS on localhost. I've used the following code in nuxt.config.js to accomplish that:
server: {
https: {
key: fs.readFileSync(path.resolve(__dirname, 'localhost-key.pem')),
cert: fs.readFileSync(path.resolve(__dirname, 'localhost.pem'))
}
},
Those are keys I created myself with mkcert. However, I'm going to be using an actual cert on the live page. Is there any way to limit that server block in nuxt.config.js to only dev mode?
I've used that in the past
NODE_ENV
was used to double check that the environment wasdevelopment
andUSE_LOCAL_HTTPS
was another variable to be sure that it was not astaging
dev environment. Of course, if you have something likestaging
ortest
for yourNODE_ENV
, you may not even need that.Otherwise, I never double-checked that but this
server
key configuration may even work only for local dev maybe. Try to give it a try, otherwise try my configuration.