How to run Vue webpack under HTTPS

09 Nov · by Tim Kamanin · 1 min read

1. You need self-signed certs at first

Generate them via this command openssl req -nodes -new -x509 -keyout server.key -out server.cert and put them into a certs dir in the root of your vue webpack project.

2. Open build/dev-server.js and add

const https = require('https')
const fs = require('fs')

to the top of the file.

3. Replace server with https server

In build/dev-server.js locate a string server = app.listen(port) and replace it with

server = https.createServer({
    key: fs.readFileSync('./certs/server.key'),
    cert: fs.readFileSync('./certs/server.cert')
}, app).listen(port);

Save your changes.

4. Run the dev server

Now type a npm run dev and your dev server should be avaialable as https://localhost:8080/


Required for comment verification