From deb0fed3f5e073427d703a9c423cf8bef6da2f42 Mon Sep 17 00:00:00 2001 From: kimyw1018 Date: Sun, 9 Aug 2026 21:38:08 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20url=20=EC=88=98=EC=A0=95=20(#176)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MR_config/local/application.example.yml | 7 +++++ .../auth/service/OAuthClientService.java | 27 ++++++++++--------- src/main/resources/application.yml | 8 +++++- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/MR_config/local/application.example.yml b/MR_config/local/application.example.yml index 5f84a3e8..e7338ec4 100644 --- a/MR_config/local/application.example.yml +++ b/MR_config/local/application.example.yml @@ -45,10 +45,17 @@ jwt: access-token-validity-in-seconds: 1800 # Access Token 만료 시간 (30분) refresh-token-validity-in-seconds: 604800 # Refresh Token 만료 시간 (7일) +# CORS 설정 +cors: + allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:3000,http://localhost:5173,https://www.musereview.site,https://musereview.site,https://musereview-sigma.vercel.app} + # 소셜 로그인 API 연동 oauth: + frontend-redirect-uri: ${OAUTH_FRONTEND_REDIRECT_URI:https://www.musereview.site/oauth/callback} frontend-redirect-uris: - http://localhost:5173/oauth/callback + - https://www.musereview.site/oauth/callback + - https://musereview.site/oauth/callback - https://musereview-sigma.vercel.app/oauth/callback temp-code-ttl: ${OAUTH_TEMP_CODE_TTL:2m} cookie: diff --git a/src/main/java/com/mr/domain/auth/service/OAuthClientService.java b/src/main/java/com/mr/domain/auth/service/OAuthClientService.java index b212eeff..f17e69a9 100644 --- a/src/main/java/com/mr/domain/auth/service/OAuthClientService.java +++ b/src/main/java/com/mr/domain/auth/service/OAuthClientService.java @@ -318,16 +318,25 @@ public String getAuthorizationUrl(SocialType socialType, String customRedirectUr return builder.build().toUriString(); } + private String resolveFrontendRedirectBaseUrl(String customFrontendRedirectUri) { + if (customFrontendRedirectUri != null && isFrontendAllowedRedirectUri(customFrontendRedirectUri)) { + return customFrontendRedirectUri.trim(); + } + if (oAuthProperties != null && oAuthProperties.frontendRedirectUri() != null && !oAuthProperties.frontendRedirectUri().isBlank()) { + return oAuthProperties.frontendRedirectUri().trim(); + } + if (oAuthProperties != null && !oAuthProperties.getAllowedFrontendRedirectUris().isEmpty()) { + return oAuthProperties.getAllowedFrontendRedirectUris().get(0); + } + return "http://localhost:5173/oauth/callback"; + } + public String buildFrontendRedirectUrl(String code) { return buildFrontendRedirectUrl(code, (String) null); } public String buildFrontendRedirectUrl(String code, String customFrontendRedirectUri) { - String baseUrl = (customFrontendRedirectUri != null && isFrontendAllowedRedirectUri(customFrontendRedirectUri)) - ? customFrontendRedirectUri.trim() - : (oAuthProperties != null && oAuthProperties.frontendRedirectUri() != null && !oAuthProperties.frontendRedirectUri().isBlank()) - ? oAuthProperties.frontendRedirectUri() - : "http://localhost:5173/oauth/callback"; + String baseUrl = resolveFrontendRedirectBaseUrl(customFrontendRedirectUri); return org.springframework.web.util.UriComponentsBuilder.fromUriString(baseUrl) .queryParam("code", code) @@ -335,18 +344,12 @@ public String buildFrontendRedirectUrl(String code, String customFrontendRedirec .toUriString(); } - - public String buildFrontendErrorRedirectUrl(String error) { return buildFrontendErrorRedirectUrl(error, (String) null); } public String buildFrontendErrorRedirectUrl(String error, String customFrontendRedirectUri) { - String baseUrl = (customFrontendRedirectUri != null && isFrontendAllowedRedirectUri(customFrontendRedirectUri)) - ? customFrontendRedirectUri.trim() - : (oAuthProperties != null && oAuthProperties.frontendRedirectUri() != null && !oAuthProperties.frontendRedirectUri().isBlank()) - ? oAuthProperties.frontendRedirectUri() - : "http://localhost:5173/oauth/callback"; + String baseUrl = resolveFrontendRedirectBaseUrl(customFrontendRedirectUri); return org.springframework.web.util.UriComponentsBuilder.fromUriString(baseUrl) .queryParam("error", (error != null && !error.isBlank()) ? error : "authentication_failed") diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d3256ff4..387b8830 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -45,11 +45,17 @@ jwt: access-token-validity-in-seconds: 1800 # Access Token 만료 시간 (30분) refresh-token-validity-in-seconds: 604800 # Refresh Token 만료 시간 (7일) +# CORS 설정 +cors: + allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:3000,http://localhost:5173,https://www.musereview.site,https://musereview.site} + # 소셜 로그인 API 연동 oauth: + frontend-redirect-uri: ${OAUTH_FRONTEND_REDIRECT_URI:https://www.musereview.site/oauth/callback} frontend-redirect-uris: - http://localhost:5173/oauth/callback - - https://musereview-sigma.vercel.app/oauth/callback + - https://www.musereview.site/oauth/callback + - https://musereview.site/oauth/callback temp-code-ttl: ${OAUTH_TEMP_CODE_TTL:2m} cookie: From 2f92f5adde8d7f515c639d2c508de7b67585b9b6 Mon Sep 17 00:00:00 2001 From: kimyw1018 Date: Sun, 9 Aug 2026 21:49:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20url=20=EC=95=88=EC=93=B0=EB=8A=94=20?= =?UTF-8?q?=EA=B2=83=20=EC=A0=95=EB=A6=AC=20(#176)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MR_config/local/application.example.yml | 4 +--- src/main/java/com/mr/global/security/SecurityConfig.java | 2 +- src/main/resources/application.yml | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/MR_config/local/application.example.yml b/MR_config/local/application.example.yml index e7338ec4..00805c29 100644 --- a/MR_config/local/application.example.yml +++ b/MR_config/local/application.example.yml @@ -47,7 +47,7 @@ jwt: # CORS 설정 cors: - allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:3000,http://localhost:5173,https://www.musereview.site,https://musereview.site,https://musereview-sigma.vercel.app} + allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:5173,https://www.musereview.site} # 소셜 로그인 API 연동 oauth: @@ -55,8 +55,6 @@ oauth: frontend-redirect-uris: - http://localhost:5173/oauth/callback - https://www.musereview.site/oauth/callback - - https://musereview.site/oauth/callback - - https://musereview-sigma.vercel.app/oauth/callback temp-code-ttl: ${OAUTH_TEMP_CODE_TTL:2m} cookie: secure: ${OAUTH_COOKIE_SECURE:false} diff --git a/src/main/java/com/mr/global/security/SecurityConfig.java b/src/main/java/com/mr/global/security/SecurityConfig.java index db06edc2..0ca86627 100644 --- a/src/main/java/com/mr/global/security/SecurityConfig.java +++ b/src/main/java/com/mr/global/security/SecurityConfig.java @@ -79,7 +79,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti return http.build(); } - @org.springframework.beans.factory.annotation.Value("${cors.allowed-origins:http://localhost:3000,http://localhost:5173,https://musereview-sigma.vercel.app}") + @org.springframework.beans.factory.annotation.Value("${cors.allowed-origins:http://localhost:5173,https://www.musereview.site}") private String allowedOrigins; // CORS 설정 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 387b8830..84e4fef8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -47,7 +47,7 @@ jwt: # CORS 설정 cors: - allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:3000,http://localhost:5173,https://www.musereview.site,https://musereview.site} + allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:5173,https://www.musereview.site} # 소셜 로그인 API 연동 oauth: @@ -55,7 +55,6 @@ oauth: frontend-redirect-uris: - http://localhost:5173/oauth/callback - https://www.musereview.site/oauth/callback - - https://musereview.site/oauth/callback temp-code-ttl: ${OAUTH_TEMP_CODE_TTL:2m} cookie: