|
7 | 7 | import jakarta.servlet.http.HttpServletResponse;
|
8 | 8 | import lombok.RequiredArgsConstructor;
|
9 | 9 | import lombok.extern.slf4j.Slf4j;
|
| 10 | +import org.springframework.beans.factory.annotation.Value; |
10 | 11 | import org.springframework.security.core.Authentication;
|
11 | 12 | import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
12 | 13 | import org.springframework.web.util.UriComponentsBuilder;
|
|
19 | 20 | public class OAuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
|
20 | 21 | private final JwtTokenProvider jwtTokenProvider;
|
21 | 22 |
|
| 23 | + @Value("frontend.redirect-url") |
| 24 | + private String frontRedirectUrl; |
| 25 | + |
| 26 | + @Value("backend.server-name") |
| 27 | + private String backServerName; |
| 28 | + |
22 | 29 | @Override
|
23 | 30 | public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
|
24 | 31 |
|
@@ -46,12 +53,12 @@ private String setRedirectUrl(String url) {
|
46 | 53 | if (url.equals("localhost")) {
|
47 | 54 | redirect_url = "http://localhost:8080/oauth/google/success";
|
48 | 55 | }
|
49 |
| - /* 프론트 개발 환경 */ |
50 |
| - if (url.equals("api.nessplanning.com")) { |
51 |
| - redirect_url = "http://localhost:3000/oauth/google/success/ing"; |
| 56 | + /* 프론트 개발 또는 프로덕션 환경 */ |
| 57 | + if (url.equals(backServerName)) { |
| 58 | + log.info("backServerName: " + backServerName); |
| 59 | + log.info("frontRedirectUrl: " + frontRedirectUrl); |
| 60 | + redirect_url = frontRedirectUrl + "/oauth/google/success/ing"; |
52 | 61 | }
|
53 |
| - //TODO: 프론트 프로덕션 환경만 지원하는 백엔드 구축 |
54 |
| - |
55 | 62 | return redirect_url;
|
56 | 63 | }
|
57 | 64 | }
|
0 commit comments