New node server locally in Vue, configuration of proxy cross-domain webpack

1. By querying the webpack documentation, we can see that the proxy configuration of webpack is configured in devServer, and his value is

config.dev.proxyTable guides the configuration to the proxyTable object under the dev object in index.js, and fills in the following code:
1 module.exports = {
 2    dev: {
 3      // .... already configured 
4     proxyTable: {
 5          "/api" : {
 6             target: 'http://127.0.0.1:8900' ,
 7             secure: false ,
 8             changeOrigin: true 
9        }
 10      }
 11    }      
 12 }    

Configure as above and restart with npm run dev.

2. Use as follows:

1 axios.get('/api/seller')
2     .then(function(res) {
3       if (!res.data.errno) {
4          console.log(res.data.data)
5       }
6     })
7     .catch(function(error) {
8       console.log(error)
9     })

3. Configure and use as above.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325281548&siteId=291194637