Excuse me: how to access multiple server addresses in the vue-cli project? Using axios

1. In the company project, two servers are deployed, one for storing data (the other server A), is used to do something similar to an evaluation system (server B);). The problem now is how to configure axios to access the contents of the two servers. I also asked the bosses to give me some advice. I appreciate it very much.

it is configured in config/dev.env.js that BASE_API:""http://172.16.0.113:8000"", is the address of A server, and
is also configured axios.defaults.baseURL = process.env.BASE_API in axios . Can you dynamically change the url, of this request in some way?
and whether can use node as the intermediate price. Forward all front-end requests to the backend to achieve access between multiple servers through node?
Please do not hesitate to give me!
this is the interface

.
export const getEva = ()=>axios({
    method:"get",
    url:"/yunhe/assetevaluation",
})

this is the set proxyTable

proxyTable: {
        "/yunhe": {
            target: "http:172.11.0.11:8080",  // 
            changeOrigin: true,  //
            pathRewrite: {
                "^/yunhe": ""   //rewrite,
            }
        }
    },

was redirected to axios.baseurl when the request was made

.

clipboard.png

Mar.03,2021

just use proxy


Don't look at Google browser. After vue-cli has used the proxy, Google network still shows the address before there is no proxy, but in fact the address of the proxy has been requested.

Menu