vue.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const { defineConfig } = require('@vue/cli-service')
  2. module.exports = defineConfig({
  3. transpileDependencies: true,
  4. publicPath:'./',
  5. // dev:{
  6. // assetsSubDirectory: 'static',
  7. // assetsPublicPath: '/',
  8. // proxyTable: { // 配置跨域
  9. // '/api':{
  10. // target:`http://localhost:8084`, //请求后台接口
  11. // changeOrigin:true, // 允许跨域
  12. // pathRewrite:{
  13. // '^/api' : '' // 重写请求
  14. // }
  15. // }
  16. // }
  17. // }
  18. devServer: {
  19. open: true,
  20. host: 'localhost',
  21. port: 8080,
  22. //这里的ip和端口是前端项目的;下面为需要跨域访问后端项目
  23. proxy: {
  24. '/ResourcesCenter': {
  25. target: 'http://localhost:8084/',//这里填入你要请求的接口的前缀
  26. ws:true,//代理websocked
  27. changeOrigin:true,//虚拟的站点需要更管origin
  28. secure: true, //是否https接口
  29. pathRewrite:{
  30. '^/ResourcesCenter':''//重写路径
  31. },
  32. headers: {
  33. referer: 'http://localhost:8084/', //这里后端做了拒绝策略限制,请求头必须携带referer,否则无法访问后台
  34. }
  35. }
  36. }
  37. }
  38. })