From a00898311a4cad82fda79c98ff64a0fbd1042374 Mon Sep 17 00:00:00 2001 From: c0smosaur Date: Wed, 5 Jun 2024 17:04:53 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20CORS=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 프론트 배포된 origin 추가 --- .../linkup/common/config/SecurityConfig.java | 4 +++- .../core/linkup/common/config/WebConfig.java | 17 ----------------- 2 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 src/main/java/com/core/linkup/common/config/WebConfig.java diff --git a/src/main/java/com/core/linkup/common/config/SecurityConfig.java b/src/main/java/com/core/linkup/common/config/SecurityConfig.java index f7e9445..03f378d 100644 --- a/src/main/java/com/core/linkup/common/config/SecurityConfig.java +++ b/src/main/java/com/core/linkup/common/config/SecurityConfig.java @@ -75,7 +75,9 @@ public PasswordEncoder passwordEncoder() { @Bean CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); - configuration.setAllowedOriginPatterns(Arrays.asList("*")); + configuration.setAllowedOriginPatterns(Arrays.asList("*", + "https://linkup-3mw.vercel.app", + "http://localhost:3000")); configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS")); configuration.setAllowedHeaders(Arrays.asList("*")); configuration.setAllowCredentials(true); diff --git a/src/main/java/com/core/linkup/common/config/WebConfig.java b/src/main/java/com/core/linkup/common/config/WebConfig.java deleted file mode 100644 index c23bdfd..0000000 --- a/src/main/java/com/core/linkup/common/config/WebConfig.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.core.linkup.common.config; - -import org.springframework.context.annotation.Configuration; -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(CorsRegistry registry) { - registry.addMapping("/**") // 모든 엔드포인트에 대해 CORS 허용 - .allowedOriginPatterns("*") // 모든 오리진 허용 - .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 허용할 HTTP 메서드 지정 - .allowedHeaders("*") // 모든 헤더 허용 - .allowCredentials(true); // JWT 사용을 위한 자격 증명 허용 - } -} \ No newline at end of file