yesman
yesman

Reputation: 7829

Run Visual Studio default Vue project in HTTPS

I have created a standard Vue application in Visual Studio 2019, using the default Vue project template. I am using Windows 10. This creates a simple project you can start up with the Vue CLI. This site runs in HTTP only, causing issues with other projects I'm debugging that only accept HTTPS.

My question: how do I force my Vue site to run in HTTPS?

Upvotes: 2

Views: 823

Answers (2)

Bowen
Bowen

Reputation: 1

I've faced a similar issue and have identified a solution tailored for individual projects.

Inside your vue project, you could set your project with vue.config.js

devServer: {
    https: true,
    proxy: {}
}

Then, you can npm run dev again and run the project in HTTPS.

Upvotes: 0

yesman
yesman

Reputation: 7829

Inside Visual Studio, right click the project containing the Vue app and select properties. Add "--https" to "Script Arguments", behind "serve". Make sure to put a space between "serve" and "--https".

Properties

There's a good chance your connection will not be secure as the SSL certificate is not recognized. You can use mkcert to create a valid HTTPS certificate. To use that, type the following commands:

  1. Install Chocolatey, a package manager:

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

  1. Install mkcert:

choco install mkcert

  1. Create a trusted CA for mkcert so its certificates are trusted:

mkcert -install

  1. create a certificate for localhost:

mkcert localhost

Restart your computer, start your solution, done.

Upvotes: 3

Related Questions