vue 跨域代理

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  devServer:{
    // 跨域代理
    proxy:{
      // 只要axios的请求中有'/api' 那就触发代理
      '/api':{
        target:'http://192.168.0.88:8888',
        // 允许跨域
        changOrigin:true,
        // 重写路径
        pathRewrite:{
          '^/api':''
        }
      }
    }
  }
})
posted @ 2024-06-04 17:02  李笑吅  阅读(3)  评论(0编辑  收藏  举报