reactjsreact-loadable

npm run build does not use proxy


I have a working react.js application, which works using npm start (app built using create-react-app). When I try to run npm run build, it builds the application. I serve it using

serve -s build -l 3000

It loads the first dashboard page but does not communicate with the server. I have put console.log statements in server to check for any requests coming in, but it never logs anything... which means the client does not talk to the server. I have proxy statement in package.json to connect to server on port 3300. This works in development mode but in production mode it seems to not pickup the proxy settings in the package.json.

Please guide... this is my first time switching to production mode... any guidance on switching to production mode would help.

BTW I use react-loadable as well...


Solution

  • The proxy field in package.json is only used in development by webpack-dev-server. You can learn more about this here