Run vuejs development server with SSL (to serve over HTTPS) Run vuejs development server with SSL (to serve over HTTPS) vue.js vue.js

Run vuejs development server with SSL (to serve over HTTPS)


I don't know if you still have this problem or if any other person still encounters it but I found a solution.

Follow the instruction above to generate an openssl key and cert in your working folder.

In /node_modules/webpack-dev-server/bin/webpack-dev-server.js change this line from:

 key: {    type: 'string',    describe: 'Path to a SSL key.',    group: SSL_GROUP  },  cert: {    type: 'string',    describe: 'Path to a SSL certificate.',    group: SSL_GROUP  },

to:

key: {    type: 'string',    describe: fs.readFileSync('key.pem'),    group: SSL_GROUP  },  cert: {    type: 'string',    describe: fs.readFileSync('cert.pem'),    group: SSL_GROUP  },

then set

argv.https = true;

That is all I had to do to have my code served from https.

Note that the command line will still read http://localhost:8080, but when you use https in the browser, your app will be displayed after warning from the browser


Requirement openssl installed :

First we have to generate SSL certificat based on a key made by openssl and without pass phrase cos this will generate an error.

nodejs https>node server.js _tls_common.js:87 c.context.setKey(options.key); ^ Error: error:0907B068:PEM routines:PEM_READ_BIO_PRIVATEKEY:bad password read ...

Go inside your project start to create key & certificat :

openssl req -nodes -new -x509 -keyout key.pem -out cert.pem -days 365

-nodes : Don't encrypt the private keys at all.

Install the packages needed for your project : (--save to add to package.json)

npm install express --savenpm install https --savenpm install fs --save

now create the server file :

touch server.jsnano server.js

Copy/Paste : to server.js

var fs = require('fs');var https = require('https');var app = require('express')();var options = {   key  : fs.readFileSync('key.pem'),   cert : fs.readFileSync('cert.pem')};app.get('/', function (req, res) {   res.send('Hello World!');});https.createServer(options, app).listen(3000, function () {   console.log('Started!');});

In this cas we don't use 443 port because is already used by services, so i use the port 3000 unused by any app...