Springboot configuration cross-domain does not work

the front and rear ends are separated, the front end uses vue, and the back end uses springboot project to start the port is inconsistent.
allows cross-domain configuration in the springboot project, but it does not work


@ Configuration
public class CorsConfig implements WebMvcConfigurer {

configuration class of

springboot

@Override
public void addCorsMappings(CorsRegistry registry) {
    registry.addMapping("/**")
            .allowedOrigins("*")
            .allowCredentials(true)
            .allowedMethods("*")
            .maxAge(3600);
}

}

did you guys write something wrong

Apr.13,2022

add @ CrossOrigin annotation to the controller layer


is the session missing? the cross-domain problem needs to cooperate with the front end, and the front paragraph has to be dealt with

.
Menu