Vue

Vue本地将开启HTTPS

2018-10-17  本文已影响232人  ChangLau

配置vue.config.js

  // 配置反向代理
  devServer: {
    proxy: {
      '/api': {
        target: 'https://172.31.120.61:8080/',
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    },
    // 开启https 访问时使用https://172.31.120.61:8081 
    // https://localhost:8081 也可以访问,不过自带info请求会报错 不清楚具体原因
    https: true
  }

运行npm run dev

 DONE  Compiled successfully in 4644ms                                                                                                                上午9:40:28


  App running at:
  - Local:   https://localhost:8081/
  - Network: https://172.31.120.61:8081/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

此时便以https启动

看看效果吧

HTTPS效果.png
上一篇下一篇

猜你喜欢

热点阅读