Skip to content

Commit

Permalink
Merge pull request #233 from 100-hours-a-week/hotfix-url
Browse files Browse the repository at this point in the history
feat: 커스텀 url 환경변수 설정
  • Loading branch information
Namgyu11 authored Sep 26, 2024
2 parents 39b0cb8 + 1cb953c commit 8ee4164
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import connectripbe.connectrip_be.post.exception.NotFoundAccompanyPostException;
import connectripbe.connectrip_be.post.repository.AccompanyPostRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -15,13 +16,14 @@ public class UrlRedirectController {

private final AccompanyPostRepository accompanyPostRepository;

@Value("${spring.customurl.success-redirect-url}")
private String successRedirectUrl;

@GetMapping("/{customUrl}")
public RedirectView redirectToOriginalUrl(@PathVariable String customUrl) {
// customUrl을 사용하여 게시글을 조회
AccompanyPostEntity post = accompanyPostRepository.findByCustomUrl(customUrl)
.orElseThrow(NotFoundAccompanyPostException::new);

// 게시글 ID를 사용하여 원래 경로로 리다이렉트
return new RedirectView("https://connectrip.travel/accompany/" + post.getId());
return new RedirectView(successRedirectUrl + post.getId());
}
}
5 changes: 5 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ spring:
url: ${DEV_DATABASE_URL}
username: ${DEV_DATABASE_USERNAME}
password: ${DEV_DATABASE_PASSWORD}

jpa:
hibernate:
ddl-auto: update
Expand Down Expand Up @@ -33,5 +34,9 @@ spring:
client-id: ${DEV_KAKAO_CLIENT_ID}
redirect-uri: ${DEV_KAKAO_REDIRECT_URI}

customurl:
success-redirect-url: ${DEV_CUSTOMURL_REDIRECT_URL}


allowed:
origins: ${DEV_ALLOWED_ORIGIN} # 허용할 오리진 설정
9 changes: 6 additions & 3 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
spring:
datasource:
driver-class-name: org.mariadb.jdbc.Driver
url: ${LOCAL_DATABASE_URL}
username: ${LOCAL_DATABASE_USERNAME}
password: ${LOCAL_DATABASE_PASSWORD}
url: ${DEV_DATABASE_URL}
username: ${DEV_DATABASE_USERNAME}
password: ${DEV_DATABASE_PASSWORD}

jpa:
hibernate:
Expand Down Expand Up @@ -36,5 +36,8 @@ spring:
client-id: ${LOCAL_KAKAO_CLIENT_ID}
redirect-uri: ${LOCAL_KAKAO_REDIRECT_URI}

customurl:
success-redirect-url: ${LOCAL_CUSTOMURL_REDIRECT_URL}

allowed:
origins: http://localhost:3000 # 허용할 오리진 설정
3 changes: 3 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ spring:
client-id: ${PROD_KAKAO_CLIENT_ID}
redirect-uri: ${PROD_KAKAO_REDIRECT_URI}

customurl:
success-redirect-url: ${PROD_CUSTOMURL_REDIRECT_URL}

allowed:
origins: ${PROD_ALLOWED_ORIGIN} # 허용할 오리진 설정

0 comments on commit 8ee4164

Please sign in to comment.