From 95ae5e8c98acbfe3fd6b75bb3ff260e80dc340b3 Mon Sep 17 00:00:00 2001 From: plum-king Date: Fri, 15 Nov 2024 05:34:02 +0900 Subject: [PATCH] =?UTF-8?q?#60=20Fix=20cors=20:=20cors=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/finut/finut_server/config/CorsMvcConfig.java | 2 +- .../java/com/finut/finut_server/config/SecurityConfig.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/finut/finut_server/config/CorsMvcConfig.java b/src/main/java/com/finut/finut_server/config/CorsMvcConfig.java index fa2c5bb..6f1a7fb 100644 --- a/src/main/java/com/finut/finut_server/config/CorsMvcConfig.java +++ b/src/main/java/com/finut/finut_server/config/CorsMvcConfig.java @@ -10,7 +10,7 @@ public class CorsMvcConfig implements WebMvcConfigurer { public void addCorsMappings(CorsRegistry corsRegistry) { corsRegistry.addMapping("/**") .allowedOrigins("http://localhost:3000") - .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD") + .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD") .allowedHeaders("Authorization", "Content-Type") .exposedHeaders("Authorization") .allowCredentials(true); diff --git a/src/main/java/com/finut/finut_server/config/SecurityConfig.java b/src/main/java/com/finut/finut_server/config/SecurityConfig.java index 3c9206d..730ac55 100644 --- a/src/main/java/com/finut/finut_server/config/SecurityConfig.java +++ b/src/main/java/com/finut/finut_server/config/SecurityConfig.java @@ -60,8 +60,7 @@ public CustomOAuth2UserService customOAuth2UserService(UsersRepository userRepos @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); - configuration.setAllowedOrigins(Arrays.asList("http://localhost:3000")); // 프론트엔드 도메인 - configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD")); // 허용할 HTTP 메서드 + configuration.setAllowedOrigins(Arrays.asList("http://localhost:3000", "http://ec2-15-165-175-91.ap-northeast-2.compute.amazonaws.com:8080")); configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD")); // 허용할 HTTP 메서드 configuration.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type")); // 허용할 헤더 configuration.setExposedHeaders(Arrays.asList("Authorization")); // 응답에서 노출할 헤더 configuration.setAllowCredentials(true); // 자격 증명 포함 요청 허용