fix(backend): fixed cors error on build dev environment

This commit is contained in:
Bernhard Müller 2026-07-27 18:26:50 +02:00
parent 3edf5cc41c
commit ca1d79acb0

View File

@ -23,6 +23,7 @@ import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
import org.springframework.security.oauth2.jwt.NimbusJwtEncoder; import org.springframework.security.oauth2.jwt.NimbusJwtEncoder;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter; import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter; import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
import org.springframework.security.oauth2.server.resource.web.HeaderBearerTokenResolver;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource; import org.springframework.web.cors.CorsConfigurationSource;
@ -61,6 +62,7 @@ public class SecurityConfig {
.anyRequest().denyAll() .anyRequest().denyAll()
) )
.oauth2ResourceServer(oauth2 -> oauth2 .oauth2ResourceServer(oauth2 -> oauth2
.bearerTokenResolver(new HeaderBearerTokenResolver("X-Access-Token"))
.jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverter())) .jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverter()))
); );