Skip to content

Commit

Permalink
refactor(main-api): 여러 프론트엔드 url을 관리할 수 있도록 함
Browse files Browse the repository at this point in the history
  • Loading branch information
inferior3x committed Jan 19, 2025
1 parent bb1471c commit cba29d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public PasswordEncoder passwordEncoder() {

//security에서 사용할 Cors 설정을 정의합니다
@Bean
public CorsConfigurationSource corsConfigurationSource(@Value("${frontend.base-url}") String frontendBaseUrl) {
public CorsConfigurationSource corsConfigurationSource(@Value("${frontend.base-urls}") List<String> frontendBaseUrls) {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.setAllowedOrigins(List.of(frontendBaseUrl));
corsConfiguration.setAllowedOrigins(frontendBaseUrls);
corsConfiguration.setAllowedMethods(List.of("*"));
corsConfiguration.setAllowedHeaders(List.of("*"));
corsConfiguration.setAllowCredentials(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
@Component
@RequiredArgsConstructor
public class LoginSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
private static final String ENDPOINT = "/oauth/success";
@Value("${frontend.base-url}")
private String frontendBaseUrl;
private static final String ENDPOINT = "/oauth/success"; //로그인 성공 시 이동시킬 엔드포인트임. 프론트가 이 페이지를 구현해야 한다.
private final CookieFactory cookieFactory;
private final UriBuilderFactory uriBuilderFactory;
private final JwtProperties jwtProperties;
Expand Down Expand Up @@ -61,8 +59,8 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
);
response.addCookie(oAuth2TempTokenCookie);
}

String uri = uriBuilderFactory.uriString( frontendBaseUrl + ENDPOINT)
String frontUrl = request.getHeader("Referer");
String uri = uriBuilderFactory.uriString( frontUrl + ENDPOINT)
.queryParam("is-registered", userInfo.isRegistered())
.build()
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ logging:
config: "classpath:logback-common.xml"

frontend:
base-url: ${FRONTEND_URL}
base-urls: ${FRONTEND_URLS}

api-key: ${API_KEY}

Expand Down

0 comments on commit cba29d1

Please sign in to comment.