Create-React-App Proxy in Production Build

2019-02-16 22:25发布

I'm using create-react-app with an express backend. I have the backend running on port 3001, and the frontend runs through port 3000 when in dev mode. I have "proxy": "http://localhost:3001" in my package.json and the api works perfectly.

When I use yarn build, however, and then run serve -s build, the api calls are simply not being made. I'm not sure why it doesn't work in production, when it does in dev.

Any help would be much appreciated.

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-02-16 23:19

The proxy feature isn't meant for production.

This might help further explain: https://github.com/facebookincubator/create-react-app/issues/1087#issuecomment-262611096

查看更多
登录 后发表回答