pyt
2025-03-24 480dda90912926b1f6fbf971f1be8fe19c2b54a3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  publicPath: './',
  devServer: {
    proxy: { //跨域配置
      "/api": { //是自定义的本地请求时的名字
        target: `http://182.140.209.168:8888`,
        changeOrigin: true, //在本地会创建一个虚拟服务端,然后发送请求的数据,并同时接收请求的数据,这样服务端和服务端进行数据的交互就不会有跨域问题
        pathRewrite: { //路径重写
          "^/api": "/api" // '^/api'是一个正则表达式,表示要匹配请求的url中,全部 '/api' 转接为 '/'
        }
      },
    }
  },
})