Enabled CORS
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()
