fix(backend): fixed cors error on build dev environment
This commit is contained in:
parent
78c3292dd9
commit
022f8e40ba
1 changed files with 3 additions and 3 deletions
|
|
@ -44,7 +44,7 @@ public class SecurityConfig {
|
|||
private String jwtSecret;
|
||||
|
||||
@Value("${app.cors-origins:http://localhost:4200}")
|
||||
private String corsOrigins;
|
||||
private List<String> corsOrigins;
|
||||
|
||||
@Bean
|
||||
public JwtDecoder jwtDecoder() {
|
||||
|
|
@ -95,7 +95,7 @@ public class SecurityConfig {
|
|||
@Bean
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
CorsConfiguration configuration = new CorsConfiguration();
|
||||
List<String> allowedPatterns = Arrays.stream(corsOrigins.split(","))
|
||||
List<String> allowedPatterns = corsOrigins.stream()
|
||||
.map(String::trim)
|
||||
.flatMap(origin -> {
|
||||
if (origin.contains("*")) {
|
||||
|
|
@ -111,7 +111,7 @@ public class SecurityConfig {
|
|||
configuration.setAllowCredentials(true);
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", configuration);
|
||||
System.out.println("LOGGED CORS ORIGINS: " + corsOrigins);
|
||||
System.out.println("LOGGED CORS ORIGINS: " + String.join(",", corsOrigins));
|
||||
return source;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue