JAVA-12390 Enabled CORS (#13208)

This commit is contained in:
Anastasios Ioannidis 2023-01-19 20:07:14 +02:00 committed by GitHub
parent 947f992d84
commit 58069ea225
1 changed files with 3 additions and 0 deletions

View File

@ -1,5 +1,7 @@
package com.baeldung.springbootsecurityrest.basicauth.config;
import static org.springframework.security.config.Customizer.withDefaults;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
@ -27,6 +29,7 @@ public class BasicAuthConfiguration {
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf()
.disable()
.cors(withDefaults())
.authorizeRequests()
.antMatchers(HttpMethod.OPTIONS, "/**")
.permitAll()