4 11

跨域:

解析后为:

 总结:这里把request.js中的

const baseURL = 'http://localhost:8080';
改为:
const baseURL = '/api';
并把vite.config.js加了:
  server:{
    proxy:{
      '/api':{//获取路径中包含了/api的请求
          target:'http://localhost:8080',//后台服务所在的源
          changeOrigin:true,//修改源
          rewrite:(path)=>path.replace(/^\/api/,'')///api替换为''
      }
    }
  }

 在4 10号里面对前端的总结依然不是最终的形式,这里又对响应拦截器进行了优化

 

posted @ 2024-04-11 13:30  你好,幸会  阅读(4)  评论(0编辑  收藏  举报