diff --git a/server/src/main/java/sunflower/server/config/WebConfig.java b/server/src/main/java/sunflower/server/config/WebConfig.java index 1707a3c..7f7ac81 100644 --- a/server/src/main/java/sunflower/server/config/WebConfig.java +++ b/server/src/main/java/sunflower/server/config/WebConfig.java @@ -1,20 +1,30 @@ package sunflower.server.config; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import static org.springframework.http.HttpHeaders.LOCATION; - @Configuration public class WebConfig implements WebMvcConfigurer { - public static final String HTTP_METHODS = "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH"; + private static final String[] ALLOWED_ORIGINS = {"**"}; @Override public void addCorsMappings(final CorsRegistry registry) { - registry.addMapping("*") - .allowedMethods(HTTP_METHODS.split(",")) - .exposedHeaders(LOCATION); + registry.addMapping("/**") + .allowedOrigins(ALLOWED_ORIGINS) + .allowedOrigins("http://localhost:80") + .allowedMethods( + HttpMethod.GET.name(), + HttpMethod.POST.name(), + HttpMethod.PUT.name(), + HttpMethod.PATCH.name(), + HttpMethod.DELETE.name(), + HttpMethod.OPTIONS.name() + ) + .allowedHeaders("*") + .exposedHeaders("Location") + .allowCredentials(true); } }