From 918249580b4ce9cb3f4c224fe3eb9e724b6b6d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20M=C3=BCller?= Date: Tue, 28 Jul 2026 12:56:07 +0200 Subject: [PATCH] fix(backend): fixed cors error on build dev environment --- .../at/mueller/eeg/backend/iam/config/SecurityConfig.java | 4 +--- eeg_backend/src/main/resources/application-dev.yml | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/eeg_backend/src/main/java/at/mueller/eeg/backend/iam/config/SecurityConfig.java b/eeg_backend/src/main/java/at/mueller/eeg/backend/iam/config/SecurityConfig.java index 16f95ac..609d4b8 100644 --- a/eeg_backend/src/main/java/at/mueller/eeg/backend/iam/config/SecurityConfig.java +++ b/eeg_backend/src/main/java/at/mueller/eeg/backend/iam/config/SecurityConfig.java @@ -77,9 +77,7 @@ public class SecurityConfig { @Bean public JwtAuthenticationConverter jwtAuthenticationConverter() { JwtGrantedAuthoritiesConverter grantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter(); - // Hier sagst du Spring, wie das Feld in deinem JWT-Payload heißt (z.B. "role" oder "roles") grantedAuthoritiesConverter.setAuthoritiesClaimName("role"); - // Spring Security erwartet bei Rollen immer das Prefix "ROLE_" grantedAuthoritiesConverter.setAuthorityPrefix("ROLE_"); JwtAuthenticationConverter jwtAuthenticationConverter = new JwtAuthenticationConverter(); @@ -93,7 +91,7 @@ public class SecurityConfig { @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); - configuration.setAllowedOrigins(Arrays.stream(corsOrigins.split(",")).map(String::trim).toList()); + configuration.setAllowedOriginPatterns(Arrays.stream(corsOrigins.split(",")).map(String::trim).toList()); configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH")); configuration.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type", "X-Access-Token")); configuration.setAllowCredentials(true); diff --git a/eeg_backend/src/main/resources/application-dev.yml b/eeg_backend/src/main/resources/application-dev.yml index 83d5236..a0827ae 100644 --- a/eeg_backend/src/main/resources/application-dev.yml +++ b/eeg_backend/src/main/resources/application-dev.yml @@ -12,7 +12,10 @@ spring: jwt: secret: dev-only-secret-do-not-use-in-production-2025 app: - cors-origins: http://localhost:4200,https://eeg.mueller-dev.com,https://*.eeg.mueller-dev.com + cors-origins: + - http://localhost:4200 + - https://eeg.mueller-dev.com + - https://*.eeg.mueller-dev.com eda: simulation: consent-delay-ms: 3000