最近在项目开发中启用本地代理后,发现自己明明写的是POST 请求结果却变成了 GET, 在网上找了好多资料,没有一个可以解决的。 最后求助公司大神,发现请求被重定向了(301),估计是请求地址是 https 的 而本地是 http 的。 最后在 devServer 中 增加了 https: true 配置解决了问题。

devServer: {
    port: port,
    open: true,
    https: true,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy: {
      '^/api': {
        target: `https://xxxxxxxxxxxxx`,
        changeOrigin: true,
        ws: true,
        logLevel: 'debug',
        pathRewrite: {
          '^/api': ''
        }
      }
   	}
  }
Logo

前往低代码交流专区

更多推荐