CORS issue - Response to preflight request doesn't pass access control check:
I am using React with Spring JWT faced similar issue as blocked by CORS policy .
added http.cors()
in my SecurityConfigurer class to resolve
@EnableWebSecurity
public class SecurityConfigurer extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable().......
}
}
And Write some lines of inside Spring boot application:
@Bean
public WebMvcConfigurer configure() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*").allowedMethods("*").allowedHeaders("Acces-Control-Allow-Origin","*");
}
};
}
This comment has been removed by the author.
ReplyDelete