The vUE project uses AXIOS to send Ajax requests. Because it is cross-domain and uses proxy reverse proxy, there is no problem in the test of development environment, but the project is packaged and put into production environment, the 404 error is reported. After checking the solution, we can set nginx backend to solve the problem, but our project server does not use Nginx. So provide a front-end solution

/ / request interceptor service. Interceptors. Request. Use (config = > {the if (process. The env. NODE_ENV = = = 'production') {const wx = / wx /, wz = /wz/; if(wx.test(config.url)) { config.url = wxApi + config.url.split(wx)[1] } if(wz.test(config.url)) { config.url = wzApi + config.url.split(wz)[1] } } return config; }, error => { console.log(error); return Promise.reject(); });Copy the code