AntdPro project cross-domain configuration

In the project created with antdPro, in the config.js file, part of the project configuration has been carried out, including the configuration code related to the proxy proxy, but it is not the proxy address we need, so we need to change it according to the project .

1. Configuration of proxy in config.js:

We can see that proxy:proxy[REACT_APP_ENV || 'dev'], according to the environment of the project, different proxy configurations are made in the proxy file.

Then we only need to make changes in the proxy.js file according to the actual situation of our project.

2. Change the cross-domain proxy of the proxy.js file:

We can see that in the proxy.js file, proxy configurations are made for the development, testing, and pre-release environments. We only need to configure the cross-domain proxy for the development environment. If we need to proxy other environments later, we can modify it under the corresponding environment.

Just replace the target in the dev environment with the address we actually want to request

Note: One thing to note here is that if you have encapsulated the request and set a unified basic path in the encapsulation, after configuring the cross-domain, you must turn off the basic path in the encapsulation, otherwise the cross-domain configuration will not success

 After the proxy is configured, our request needs to be prefixed with /devServer when requesting the proxy, so that the request can be proxied to the address we actually want to request

 

Guess you like

Origin blog.csdn.net/fsfsdgsdg/article/details/125246516