Skip to content

Commit

Permalink
Merge pull request #193 from APPS-sookmyung/dev
Browse files Browse the repository at this point in the history
[Feat] CORS 오류 수정
  • Loading branch information
ajung7038 authored Dec 25, 2024
2 parents 0898123 + cd7887b commit 7d8ed77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/WELLET/welletServer/config/CorsMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public void addCorsMappings(CorsRegistry corsRegistry) {

corsRegistry.addMapping("/**")
.exposedHeaders("Set-Cookie")
.allowedOrigins("http://localhost:8000")
.allowedOrigins(frontendUrl);// 프론트 서버 주소
.allowedOrigins("http://localhost:8000", frontendUrl)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 허용할 HTTP method
.allowCredentials(true); // 쿠키 인증 요청 허용
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ public String callback(@RequestParam("code") String code, HttpServletResponse re
jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정
jwtCookie.setPath("/"); // 쿠키를 모든 경로에 적용

// response.setHeader("Set-Cookie","token=" + jwtToken +. ;Path=/; Domain=localhost; HttpOnly; Max-Age=604800; SameSite=None; Secure;");

response.setHeader(
"Set-Cookie",
"token=" + jwtToken
+ "; Path=/"
+ "; Domain=localhost"
+ "; HttpOnly"
+ "; Max-Age=604800"
+ "; SameSite=None"
+ "; Secure"
);


// jwtCookie.setDomain(frontendUrl);
response.addCookie(jwtCookie);

Expand Down

0 comments on commit 7d8ed77

Please sign in to comment.