Vue front-end cross-domain configuration

  • First install axios
npm install axios
  • Secondly, in the modified proxyTable index.js in the config
     
    proxyTable: {
       '/ fire' : {
        target: 'http://127.0.0.1:8000' , 
         // Secure: to false, // if https interface need to configure this parameter 
        changeOrigin: to true ,
        Pthriawrite: {
          '^/api': ''
        }
      }
    },
  • Finally, in the main.js their registration (Note that in addition to modify a file in src, the need to restart npm)
import axios from 'axios'


Vue.prototype.axios = axios

Guess you like

Origin www.cnblogs.com/u-damowang1/p/12131085.html