How does create-react-app set up api agents in production and test environments

for example, the address of my test environment is https://www.google.com
. Then how should I set up build.js and start.js under scripts file without frequently switching proxy
under package.json? What should be set?

Mar.20,2021

build a project using create-react-app, for example, using axios,
Development Environment
in the package.json file, add (just add to the bottom curly braces)
"proxy": "http://localhost:9093/"
means that the request has been forwarded to http://localhost:8080/

production environment requires nginx to forward


if you use axios, you can configure the unified request path. (the production environment address
proxy writes the test environment address normally.


don't know what you mean? If it is a local link for production debugging, you can add a localstorage attribute to your environment configuration file to judge, and modify the environment configuration parameters dynamically through the console to modify localstorage.

Menu