From bb0f3dc7721031ced0f76bed11c319cf6ab2def5 Mon Sep 17 00:00:00 2001 From: dlrjs2360 Date: Tue, 26 Dec 2023 16:38:57 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20fix:=20cors=20origin=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit preflight 요청에 대한 캐시 저장 기간을 설정하고 헤더에 "Access-Control-Allow-Origin"을 추가했습니다. --- .../java/com/HowBaChu/howbachu/config/CorsConfig.java | 9 +++++---- src/main/java/com/HowBaChu/howbachu/jwt/JwtFilter.java | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/HowBaChu/howbachu/config/CorsConfig.java b/src/main/java/com/HowBaChu/howbachu/config/CorsConfig.java index f186b9a..373f8e5 100644 --- a/src/main/java/com/HowBaChu/howbachu/config/CorsConfig.java +++ b/src/main/java/com/HowBaChu/howbachu/config/CorsConfig.java @@ -11,9 +11,10 @@ public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") - .allowedOriginPatterns("*") - .allowedMethods("*") - .allowedHeaders("*") - .allowCredentials(true); + .allowedOriginPatterns("*") + .allowedMethods("*") + .allowedHeaders("*") + .allowCredentials(true) + .maxAge(3600L); } } \ No newline at end of file diff --git a/src/main/java/com/HowBaChu/howbachu/jwt/JwtFilter.java b/src/main/java/com/HowBaChu/howbachu/jwt/JwtFilter.java index 8896835..8fa91f4 100644 --- a/src/main/java/com/HowBaChu/howbachu/jwt/JwtFilter.java +++ b/src/main/java/com/HowBaChu/howbachu/jwt/JwtFilter.java @@ -47,6 +47,8 @@ public void doFilterInternal(HttpServletRequest request, HttpServletResponse res resolveTokenFromCookie(request, REFRESH_TOKEN_HEADER), request, response); + response.setHeader("Access-Control-Allow-Origin", "*"); + chain.doFilter(request, response); }