BiangBaing 2022-11-01 09:29 采纳率: 60%
浏览 31

webpack创建的vue项目配置https

问题遇到的现象和发生背景

需求:app嵌入型h5项目,实现二维码扫描功能。
在网上找了几个案例,但都是需要在https下才能正常运行。
问题就是项目中配置的https无效,不清楚到底应该如何配置

用代码块功能插入代码,请勿粘贴截图

"webpack": "^3.6.0", 使用的webpack版本
config/index.js文件,这是配置项


module.exports = {
  dev: {
    // Paths
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    // host: 'localhost', // can be overwritten by process.env.HOST
    host:'192.168.1.84',
    // host: '127.0.0.1',
    port: 80, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
    https: true,
    devtool: 'cheap-module-eval-source-map',
    cacheBusting: true,
    cssSourceMap: true,
    proxyTable: {
      '/test': {
        target: 'https://api',
        changeOrigin: true,
        secure:false,
        pathRewrite: {
          '^/test': ''
        },
        ws:false  // 
      },
     
    },
  },
   

  build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),
  },

}

我的解答思路和尝试过的方法

我看别人的都是在 devServer 中配置的,我在另外一个vue-cli项目中试了一下,也可以,但是我这个项目是webpack创建的vue项目,在dev中配置https就无效了。

我想要达到的结果

使本地项目能够在 https 上运行

  • 写回答

2条回答 默认 最新

  • 天問_ 2022-11-01 10:49
    关注

    这个写的还可以,可以参考一下。

    https://www.jianshu.com/p/dabe3c249f3e

    评论

报告相同问题?

问题事件

  • 创建了问题 11月1日