美文网首页
vue 从http地址转移到https上

vue 从http地址转移到https上

作者: 兔子不打地鼠打代码 | 来源:发表于2019-03-26 14:30 被阅读0次

方案一:
在 build/webpack.dev.conf.js 的devServer下增加https:true,

 devServer: {
    clientLogLevel: 'warning',
    historyApiFallback: {
      rewrites: [
        {from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html')},
      ]
    },
    https:true,
......
}

方案二:
补全 static/config.js 里的api地址

window.appConfig = {
  env: {
    'localhost': {
      api: 'https//test-api-smarthos.diandianys.com/app',
      api2: '//192.168.1.29:8081',
      // api2: '//192.168.1.189:8089',
      pay_project: 'zsyy_test',
      tjyy: 'test-tjyy-api.hztywl.cn',
      tjyy_pay_project: 'zsyy_tjyy_test',
      // appid: 'wx6e3551dee5f7e716',
      appid: 'wxa49f90b4ff678ef2', //标准版
      plat: 'dev'
    }
}
}
image.png

修改 src/lib/http.js 中的url 去除url头部的双//

 return new Promise((resolve, reject) => {
    // loading && (load = weuijs.loading('加载中...'));
    loading && (bus.$emit('loading', '加载中...'))
    let axiosConfig = {
      url: `${env.api}`,
      method,
      data,
      headers: {
        sign: 'test'
      }
    }
image.png

相关文章

网友评论

      本文标题:vue 从http地址转移到https上

      本文链接:https://www.haomeiwen.com/subject/rzmgvqtx.html