简体   繁体   English

如何在 Windows 上使用 https 运行 Vue-cli 项目

[英]How to run Vue-cli project using https on Windows

I am trying to run a vue-cli project using https.我正在尝试使用 https 运行 vue-cli 项目。

As per the instructions here How to run Vue.js dev serve with https?按照此处的说明How to run Vue.js dev serve with https?

I've added the https setting to the vue.config.js as per below我已将 https 设置添加到vue.config.js ,如下所示

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

When I run the app it correctly runs as https://localhost:8080 however Chrome throws an ERR_CERT_AUTHORITY_INVALID error.当我运行该应用程序时,它以https://localhost:8080正确运行,但是 Chrome 会引发 ERR_CERT_AUTHORITY_INVALID 错误。

It appears I need to setup an SSL certificate in Windows and set some configuration in vue.config.js.看来我需要在 Windows 中设置一个 SSL 证书并在 vue.config.js 中设置一些配置。 Does anyone know how to do this?有谁知道如何做到这一点? Note, this question applies specifically to Windows.请注意,这个问题特别适用于 Windows。

This happened to me when I was building multiple applications that were sometimes sharing the same port.当我构建多个有时共享同一个端口的应用程序时,这发生在我身上。 I fixed it by switching to a different port:我通过切换到不同的端口来修复它:

module.exports = {
   devServer: {
     port: 8081
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM