vue.config.js 1.1 KB

123456789101112131415161718192021222324
  1. const path = require('path')
  2. const resolve = dir => {
  3. return path.join(__dirname, dir)
  4. }
  5. module.exports = {
  6. publicPath: './',
  7. chainWebpack: config => {
  8. config.resolve.alias
  9. .set('_c', resolve('src/components')) // key,value自行定义,比如.set('@@', resolve('src/components'))
  10. },
  11. devServer: {
  12. proxy: {
  13. "/mes":{ // /proxy_url 这个用来和根路径 baseURL 进行匹配
  14. //target:'http://168.0.9:8099/mes',
  15. target: 'http://10.10.6.28:8099/mes', // 'http://localhost:8099/uas/' ,这个是填写跨域的请求域名+端口号,也就是要请求的URL(不包含URL路径)
  16. changeOrigin: true, // 是否允许跨域请求,在本地会创建一个虚拟服务端,然后发送请求的数据,并同时接收请求的数据,这样服务端和服务端进行数据的交互就不会有跨域问题
  17. pathRewrite: { // 路径重写
  18. '^/mes': '' // 替换target中的请求地址,原请求为 http://127.0.0.1:8000/kuayu 实际请求为 http://127.0.0.1:8000/proxy_url/kuayu
  19. }
  20. }
  21. }
  22. }
  23. }