反应webpack配置代理不稳定

时间:2018-10-25 02:36:32

标签: reactjs webpack create-react-app

我在package.json中具有以下配置

"proxy": "https://l94wc2001h.execute-api.ap-southeast-2.amazonaws.com",

我在应用程序中也有一个ajax调用,即使我不更改代码,它有时也会成功传递,有时会出现如下错误:

Proxy error: Could not proxy request /api/xxx from localhost:3000 to https://l94wc2001h.execute-api.ap-southeast-2.amazonaws.com

我还尝试更改为使用http-proxy-middleware来配置高级代理,如下所示:

target: 'https://l94wc2001h.execute-api.ap-southeast-2.amazonaws.com',
secure: false,
changeOrigin: true

它也提供相同的信息:

[HPM] Error occurred while trying to proxy request /api/xxx from localhost:3000 to https://l94wc2001h.execute-api.ap-southeast-2.amazonaws.com

有人可以帮我吗?

0 个答案:

没有答案