Vue cli serve with https

I generated a Vue project using the new Vue CLI 3. Is there a way to npm run serve my project using https?

1 Like

It should be possible, but you’ll have to generate your own SSL certificate first.

This looks like a good solution but I was hoping for a simpler out of the box solution using the new CLI without having to build a node server. I understand this exists in Angular and was thinking maybe Vue has something similar.

Oh actually it’s already possible :grin:

vue.config.js

module.exports = {
  devServer: {
    https: true
  }
}

https://webpack.js.org/configuration/dev-server/#devserver-https

4 Likes

It works!! Thank you so much!

Vue-cli has a --https option for vue-cli, run yarn serve --https or vue-cli-service service --https and it will serve on https://localhost:8080 without changes to your code.

https://cli.vuejs.org/guide/cli-service.html#vue-cli-service-serve