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