Several methods to achieve cross-domain

1.jsonp javascript tags src achieve, can only send get request

2.cors background configuration required to allow cross-domain 

3. Proxy Server

vue.config.js in cross-domain configuration

devServer: {

     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       '/api' : {
         target: `http: //10.24.4.214:8098/api`,
         changeOrigin:  true ,
         pathRewrite: {
           '^/api'  ''
         }
       }
     }
}

Guess you like

Origin www.cnblogs.com/dgmoba/p/12615847.html