Webpack开发服务器代理无法正确重定向

时间:2019-03-18 16:12:15

标签: javascript webpack webpack-dev-server

我在webpack开发服务器上遇到了一个奇怪的问题。代理记录它正在重写URL,但未对更新的URL发出实际请求(根据快递日志)

这是我得到的输出

[HPM] Rewriting path from "/clients/123abc/plans" to "https://api.mycustomhost.com/api/clients/123abc/plans"

[HPM] GET /clients/123abc/plans ~> https://api.mycustomhost.com/api

[HPM] Rewriting path from "/clients/123abc/plans?type=dc" to "https://api.mycustomhost.com/api/clients/123abc/plans?type=dc"

[HPM] POST /clients/123abc/plans?type=dc ~> https://api.mycustomhost.com/api

[HPM] Rewriting path from "/clients/123abc/plans" to "https://api.mycustomhost.com/api/clients/123abc/plans"

[HPM] GET /clients/123abc/plans ~> https://api.mycustomhost.com/api

我的webpack代理配置

proxy: {
    '/clients/**': {
        target: options.webpackOptions.endpoint,
        changeOrigin: true,
        logLevel: 'debug',
        secure: false,
        pathRewrite: {
            '^/clients': (_path) => options.webpackOptions.endpoint + _path
        }
    }
}

我在做什么错了?

更多信息:

  • 后端是.NET服务器
  • Webpack-> 4.1.1
  • WebpackDevServer-> 3.1.1

TIA

0 个答案:

没有答案