hejianhao
2025-09-12 34387905766d41cbca973488df03b9157ad297c6
vue.config.js
@@ -1,3 +1,8 @@
const path = require('path')
function resolve(dir) {
  return path.join(__dirname, dir)
}
module.exports = {
  publicPath: './',
  // publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
@@ -8,8 +13,7 @@
  devServer: {
    proxy: { //跨域配置
      "/api": { //是自定义的本地请求时的名字
        // target: "http://192.168.110.64:8000",
        target: "http://vwpmxwbhv59i.guyubao.com",
        target: "",
        changeOrigin: true, //在本地会创建一个虚拟服务端,然后发送请求的数据,并同时接收请求的数据,这样服务端和服务端进行数据的交互就不会有跨域问题
        pathRewrite: { //路径重写
          "^/api": "/" // '^/api'是一个正则表达式,表示要匹配请求的url中,全部 '/api' 转接为 '/'
@@ -25,4 +29,11 @@
      }
    }
  },
  configureWebpack: {
    resolve: {
      alias: {
        '@': resolve('src'),
      }
    }
  }
}