springboot+shiro+vue前后端分离导致用户登录失效问题

springboot+shiro+vue前后端分离导致用户登录失效问题

前端后分离、导致用户登录token失效

@Configuration
public class CrossDomain extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*")
.allowedMethods(“GET”, “HEAD”, “POST”, “PUT”, “DELETE”, “OPTIONS”)
.allowCredentials(true) // 需要开启,否者前端无法获取shiro传递的cookie
.maxAge(3600);
}
}
后端代码需要增加跨域处理,并且allowCredentials(true)属性要设置为true
前端代码ajax请求allowCredentials(true)属性也要设置为true

发布了10 篇原创文章 · 获赞 0 · 访问量 14

猜你喜欢

转载自blog.csdn.net/weixin_41141000/article/details/105485876