vue3 proxy代理出现的严重bug

在Vue项目的vue.config.js中设置了代理,其中一个请求/dpi/data_api_statistic/overview返回404错误,而另一个/dpi/data_api_statistic/api_calls请求则成功。问题可能与pathRewrite配置或者请求路径有关。开发者正在寻找遇到类似问题的大佬进行讨论。
摘要由CSDN通过智能技术生成

 vue.config.js 中代理

const { defineConfig } = require("@vue/cli-service");
require('events').EventEmitter.defaultMaxListeners = 0;
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  // // 基本路径,相对路径
  // publicPath: process.env.NODE_ENV === "production" ? "./" : "./",
  // outputDir:process.env.outputDir, // 输出文件目录 outputDir: ,
  devServer: {
    port: 8090,
    proxy: {
        "/dpi": {
            target: "http://xxx.xxx.xx.xxx:8090/api/",
            changeOrigin : true,
            ws: true,
            secure: false,
            logLevel: "debug",
            pathRewrite: {
              "^/dpi": "",
            },
      },

}

页面中 写法一致

const getView = async () => {
      await proxy.$http
        .get("/dpi/data_api_statistic/overview")
        .then((res) => {
          if (res.code == 200) {
            
          }
        })
        .catch((err) => {
          console.log(err);
        });
    };
    const getViewEchart = async () => {
      await proxy.$http
        .get("/dpi/data_api_statistic/api_calls")
        .then((res) => {
          if (res.code == 200) {
          }
        })
        .catch((err) => {
          console.log(err);
        });
    };

网页中 一个报错404  一个成功

 

 有没有大佬出现类似的问题  可以讨论一下!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值