From b33cc48049c2be891fe25999a6378574889707b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D?= Date: Tue, 20 Aug 2024 03:02:53 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20cors=20url=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../itpick/backend/config/SecurityConfig.java | 32 +++++++++---------- .../itpick/backend/config/WebConfig.java | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/store/itpick/backend/config/SecurityConfig.java b/src/main/java/store/itpick/backend/config/SecurityConfig.java index 2167ff1..92dfabb 100644 --- a/src/main/java/store/itpick/backend/config/SecurityConfig.java +++ b/src/main/java/store/itpick/backend/config/SecurityConfig.java @@ -32,7 +32,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http .csrf(AbstractHttpConfigurer::disable) // CSRF 보호 비활성화 - .cors(withDefaults()) // CORS 설정 추가 +// .cors(withDefaults()) // CORS 설정 추가 .formLogin(FormLoginConfigurer::disable) // 폼 로그인 비활성화 .sessionManagement(sessionManagement -> sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS) // 세션 관리 정책 설정 @@ -42,19 +42,19 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { return http.build(); } - @Bean - public CorsFilter corsFilter() { - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - CorsConfiguration config = new CorsConfiguration(); - config.setAllowCredentials(true); - config.addAllowedOrigin("https://itpick.netlify.app"); - config.addAllowedOrigin("http://localhost:3000"); - config.addAllowedOrigin("http://localhost:5173"); - config.addAllowedOrigin("https://localhost:5173"); - config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")); - config.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token", "Accept", "X-Requested-With")); - config.setExposedHeaders(Arrays.asList("Authorization", "location")); - source.registerCorsConfiguration("/**", config); - return new CorsFilter(source); - } +// @Bean +// public CorsFilter corsFilter() { +// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); +// CorsConfiguration config = new CorsConfiguration(); +// config.setAllowCredentials(true); +// config.addAllowedOrigin("https://itpick.netlify.app"); +// config.addAllowedOrigin("http://localhost:3000"); +// config.addAllowedOrigin("http://localhost:5173"); +// config.addAllowedOrigin("https://localhost:5173"); +// config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")); +// config.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token", "Accept", "X-Requested-With")); +// config.setExposedHeaders(Arrays.asList("Authorization", "location")); +// source.registerCorsConfiguration("/**", config); +// return new CorsFilter(source); +// } } diff --git a/src/main/java/store/itpick/backend/config/WebConfig.java b/src/main/java/store/itpick/backend/config/WebConfig.java index c20605e..a2759d8 100644 --- a/src/main/java/store/itpick/backend/config/WebConfig.java +++ b/src/main/java/store/itpick/backend/config/WebConfig.java @@ -47,7 +47,7 @@ public void addArgumentResolvers(List resolvers) public void addCorsMappings(CorsRegistry registry) { log.info("CorsMapping이 호출 되었습니다."); registry.addMapping("/**") - .allowedOrigins("http://localhost:3000", "http://localhost:5173", "https://localhost:5173", "https://itpick.netlify.app","https://itpick.vercel.app","https://deploy-preview-107--itpick.netlify.app","https://deploy-preview-85--itpick.netlify.app","https://deploy-preview-99--itpick.netlify.app") + .allowedOrigins("http://localhost:3000", "http://localhost:5173", "https://localhost:5173", "https://itpick.netlify.app","https://itpick.vercel.app","https://deploy-preview-107--itpick.netlify.app","https://deploy-preview-85--itpick.netlify.app","https://deploy-preview-99--itpick.netlify.app","https://deploy-preview-129--itpick.netlify.app") .allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH","OPTIONS") .exposedHeaders("location", "Authorization") .allowedHeaders("Content-Type", "Authorization", "X-Requested-With", "Accept")