0

We have an API that we host via nginx on localhost:3128. That API serves all of our JS/HTML as well as our various service endpoints.

If I run yarn start that will run on port 3000, which means that our fetch requests also go to port 3000, and that won't work since the endpoints are all on 3128.

My plan was to instead run a build, and then upload to our serving API behind nginx for testing. The problem is that yarn build transforms our human readable typescript into minified, compiled javascript. This makes my stack traces and debugging harder.

How can I solve this problem?

AMP_035
  • 167
  • 1
  • 2
  • 13
  • Does this answer your question? [How to build a production version of React without minification?](https://stackoverflow.com/questions/55165466/how-to-build-a-production-version-of-react-without-minification) – Rohan Agarwal Mar 08 '21 at 19:01
  • Thanks for the recommendation, I tried what was suggested in that post and unfortunately wasn't able to get unminified stack-traces. :( – AMP_035 Mar 08 '21 at 19:14

1 Answers1

1

General solution to this would be to create some proxy that would redirect your requests from :3000 to :3128. If you use CRA, you can declare proxy in package.json or setupProxy.js.

If you don't use CRA, but use webpack, it is made in similar fashion with webpack-dev-server.

Mr. Hedgehog
  • 2,644
  • 1
  • 14
  • 18
  • Thank you so much! This worked wonderfully and you've saved me so much time. I really appreciate your insight, don't think I could have gotten there on my own! – AMP_035 Mar 08 '21 at 21:22
  • It is good thing that you told us why you want to add non minified react to production. Otherwise, there could be absolutely different answer. – Mr. Hedgehog Mar 08 '21 at 21:50