diff --git a/src/main/java/dev/goormthon/ppoori/global/config/WebConfig.java b/src/main/java/dev/goormthon/ppoori/global/config/WebConfig.java index 2a992b1..6cb89a8 100644 --- a/src/main/java/dev/goormthon/ppoori/global/config/WebConfig.java +++ b/src/main/java/dev/goormthon/ppoori/global/config/WebConfig.java @@ -1,17 +1,24 @@ package dev.goormthon.ppoori.global.config; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; @Configuration -public class WebConfig implements WebMvcConfigurer { +public class WebConfig { - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/api/**") - .allowedOrigins("https://jejucart-front.vercel.app", "http://localhost:3000", "https://ppoori.shop/api/v1/docs") - .allowedMethods("HEAD", "OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE") - .allowCredentials(true); + @Bean + public CorsFilter corsFilter() { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + CorsConfiguration config = new CorsConfiguration(); + config.setAllowCredentials(true); + config.addAllowedOriginPattern("*"); + config.addAllowedHeader("*"); + config.addAllowedMethod("*"); + + source.registerCorsConfiguration("/api/**", config); + return new CorsFilter(source); } }