vue.config.js 文件配置跨域(低配版)

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    host:'localhost',
    open: true, // 浏览器自动打开
    port: 3000,  //修改启动的端口号
    proxy: {
            '/api': {//请求接口中要替换的标识
                     target:'http://baidu.com',//代理地址
                    pathRewrite: {"/api" : ""}, // 后台在转接的时候url中是没有 /api 的
            }
      }
  }
})
            

 

posted @ 2022-09-26 23:16  kai·james  阅读(400)  评论(0)    收藏  举报