Answers for "how to enable cors in spring boot security"

2

spring security enable global cors

@Override
	public void configure(HttpSecurity http) throws Exception {
		http.cors().configurationSource(request -> new CorsConfiguration().applyPermitDefaultValues())
 		// ...
	}


	@Bean
	public WebMvcConfigurer corsConfigurer() {
		return new WebMvcConfigurer() {
			@Override
			public void addCorsMappings(CorsRegistry registry) {
				registry.addMapping("/**")
				.allowedOrigins("*")
				.allowedMethods("GET", "PUT", "POST", "PATCH", "DELETE", "OPTIONS");
			}
		};
	}
Posted by: Guest on December-23-2020
0

how to disable the cors in spring boot

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

	@Override
	protected void configure(HttpSecurity http) throws Exception {
		http.cors().and()...
	}
}
Posted by: Guest on June-12-2021

Code answers related to "how to enable cors in spring boot security"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language