fix(backend): fixed cors error on build dev environment
This commit is contained in:
parent
abadc60ef0
commit
918249580b
2 changed files with 5 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue