Updated CORS to use a property

This commit is contained in:
2024-04-27 16:23:05 -04:00
parent 3b9a984659
commit 4a5a221605
3 changed files with 34 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
package com.mattrixwv.cipherstream.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
@@ -11,9 +12,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Component
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer{
@Value("${allowedOrigins}")
private String allowedOrigins;
@Override
public void addCorsMappings(@NonNull CorsRegistry registry){
registry.addMapping("/**")
.allowedOriginPatterns("http://localhost:3000");
.allowedOriginPatterns(allowedOrigins);
}
}