0
点赞
收藏
分享

微信扫一扫

webpack5学习与实战-(十一)-devServer

素的盐 2022-04-05 阅读 29
vue.js
 devServer: {
    // 任意的 404 响应都被替代为 index.html
    // 基于node connect-history-api-fallback包实现,主要应用于history路由刷新页面404的场景
    historyApiFallback: true,
    compress: true,//为响应增加gzip压缩
    // 在所有响应中添加首部内容
    headers: {
      "X-Custom-Foo": "test-header"
    },
    hot: true, //模块的热替换
    // 是否自动打开浏览器
    open: true,
    // 设置本地url和端口号
    port: 3001,
    // 代理
    proxy: {
      "/api": {
        secure: false,
        host: "0.0.0.0", //这个配置了同一局域网访问ip可以访问本项目
        changeOrigin: true,
        target: "http://42.192.69.45", // 外网接口域名 即http://localhost:8080/api/123 = http://42.192.69.45:3001/api/123
        pathRewrite: { "^/api": "" } //把http://42.192.69.45:3001/api/123变成http://42.192.69.45:3001/123
      }
    }
  },
举报

相关推荐

0 条评论