How to run Nuxt2 with HTTPS in Windows
Using Nuxt2 and version 3 of Nuxt with Storyblok would require HTTPS for development.
To serve Nuxt2 with HTTPS, follow the steps below.
- Navigate to your project's main directory
- Create a public and private key as shown in the code block belowkeys
openssl genrsa 2048 > server.key chmod 400 server.key openssl req -new -x509 -nodes -sha256 -days 365 -key server.key -out server.crt
- Add your server requirements to your
nuxt.config.js
filenuxt.config.jsimport path from 'path' import fs from 'fs'
- Add your server configuration to your
nuxt.config.js
filenuxt.config.jsserver: { https: { key: fs.readFileSync(path.resolve(__dirname, 'server.key')), cert: fs.readFileSync(path.resolve(__dirname, 'server.crt')) } }
HINT:
If you're a macOS user, you should check out the setup for HTTPS on MacOS.