• 安装中间件npm install http-proxy-middleware(可以配置多个代理)

      1. //在src目录下新建setupProxy.js文件
      2. const proxy=require('http-proxy-middleware')
      3. module.exports=function(app){
      4. app.use(proxy.createProxyMiddleware('/api',{
      5. target:'https://meet.bjnsc.usingnet.com',
      6. secure:false,
      7. changeOrigin:true,
      8. pathRewrite:{
      9. "^/api":"/api"
      10. }
      11. }))
      12. }
    • 使用

      this.$axios.get("/api/auth/login").then(res => {
      console.log(res)
      })