diff --git a/src/main/java/com/moddy/server/config/cors/WebConfig.java b/src/main/java/com/moddy/server/config/cors/WebConfig.java new file mode 100644 index 00000000..c682bc41 --- /dev/null +++ b/src/main/java/com/moddy/server/config/cors/WebConfig.java @@ -0,0 +1,20 @@ +package com.moddy.server.config.cors; + +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; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + + @Override + public void addCorsMappings(final CorsRegistry registry) { + registry.addMapping("/**") + .allowedOriginPatterns("*") + .allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), HttpMethod.DELETE.name()) + .allowedHeaders("Authorization", "Content-Type") + .allowCredentials(true) + .maxAge(3000); + } +} \ No newline at end of file