toesbieya / jxc-admin

一个前后端分离的简易进销存后台管理系统,基于SpringBoot和vue-element-admin实现,具备常见的后台管理功能,登录态使用session,使用基于资源url的简单权限控制。
https://toesbieya.cn/jxc-admin
MIT License
349 stars 118 forks source link

退出和刷新提示请登录后重试 #8

Closed zhezi closed 4 years ago

zhezi commented 4 years ago

{"msg":"请登录后重试","status":401,"success":false}

toesbieya commented 4 years ago

刚才试了在线预览的,没出现这问题啊,具体操作步骤是啥

zhezi commented 4 years ago

1.修改vue中src/config/index.js apiPrefix:'/' 2.npm run serve 3.启动后端local服务

toesbieya commented 4 years ago

首先,此问题应该只会出现在开发阶段

如果非要用'/'的话,那么把config.js里的route.mode改为'hash'

原因也简单,比如登录页地址是'http://localhost/login',那么在你刷新或者在浏览器地址栏键入并回车时,会向devServer发送一个'/login'get请求,'/login'会被设置的apiPrefix匹配,所以devServer会把这个请求转发给后端服务,由于这个请求并不是axios发出的,所以请求头上没有带校验用户身份的标识,从而被拦截。退一万步讲,即使带上了身份标识,后端也会返回404页面。