Springboot + shiro + vue separation of front and back ends leads to user login failure

Springboot + shiro + vue separation of front and back ends leads to user login failure

After the front end is separated, the user login token is invalid

@Configuration
public class CrossDomain extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings (CorsRegistry registry) {
registry.addMapping ("/ **").
AllowedOrigins (" *") .allowedMethods ("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
.allowCredentials (true) // Need to be enabled, otherwise the front end cannot obtain the cookie passed by shiro
.maxAge (3600);
}
} The
back-end code needs to increase cross-domain processing and allowCredentials The (true) attribute should be set to true. The
front-end code ajax request allowCredentials (true) attribute should also be set to true

Published 10 original articles · praised 0 · visits 14

Guess you like

Origin blog.csdn.net/weixin_41141000/article/details/105485876