const { defineConfig } = require('@vue/cli-service') module.exports = defineConfig({ transpileDependencies: true, publicPath:'./', // dev:{ // assetsSubDirectory: 'static', // assetsPublicPath: '/', // proxyTable: { // 配置跨域 // '/api':{ // target:`http://localhost:8084`, //请求后台接口 // changeOrigin:true, // 允许跨域 // pathRewrite:{ // '^/api' : '' // 重写请求 // } // } // } // } devServer: { open: true, host: 'localhost', port: 8080, //这里的ip和端口是前端项目的;下面为需要跨域访问后端项目 proxy: { '/ResourcesCenter': { target: 'http://localhost:8084/',//这里填入你要请求的接口的前缀 ws:true,//代理websocked changeOrigin:true,//虚拟的站点需要更管origin secure: true, //是否https接口 pathRewrite:{ '^/ResourcesCenter':''//重写路径 }, headers: { referer: 'http://localhost:8084/', //这里后端做了拒绝策略限制,请求头必须携带referer,否则无法访问后台 } } } } })