Skip to content

Commit

Permalink
feat : ev, production 서버 api 주소 설정 (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
BadaHertz52 authored Aug 21, 2024
1 parent 51b1730 commit 489d0d7
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions frontend/src/apis/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
export const VERSION2 = 'v2';

const getDevServerUrl = () => {
const serverUrlList = process.env.API_BASE_URL?.split('//');
if (!serverUrlList) return '';
return serverUrlList[0] + '//' + 'dev-' + serverUrlList[1];
};

const getServerUrl = () => {
const isProduction = window?.location.hostname === 'review-me.page';
const devServerUrl = getDevServerUrl();

return isProduction ? process.env.API_BASE_URL : devServerUrl;
};

const serverUrl = getServerUrl();

export const DETAILED_REVIEW_API_PARAMS = {
resource: 'reviews',
queryString: {
Expand Down Expand Up @@ -37,21 +52,21 @@ export const REVIEW_GROUP_DATA_API_PARAMS = {
},
};

export const REVIEW_WRITING_API_URL = `${process.env.API_BASE_URL}/${VERSION2}/${REVIEW_WRITING_API_PARAMS.resource}`;
export const REVIEW_LIST_API_URL = `${process.env.API_BASE_URL}/${VERSION2}/${REVIEW_LIST_API_PARAMS.resource}`;
export const DETAILED_REVIEW_API_URL = `${process.env.API_BASE_URL}/${VERSION2}/${DETAILED_REVIEW_API_PARAMS.resource}`;
export const REVIEW_GROUP_DATA_API_URL = `${process.env.API_BASE_URL}/${VERSION2}/${REVIEW_GROUP_DATA_API_PARAMS.resource}`;
export const REVIEW_WRITING_API_URL = `${serverUrl}/${VERSION2}/${REVIEW_WRITING_API_PARAMS.resource}`;
export const REVIEW_LIST_API_URL = `${serverUrl}/${VERSION2}/${REVIEW_LIST_API_PARAMS.resource}`;
export const DETAILED_REVIEW_API_URL = `${serverUrl}/${VERSION2}/${DETAILED_REVIEW_API_PARAMS.resource}`;
export const REVIEW_GROUP_DATA_API_URL = `${serverUrl}/${VERSION2}/${REVIEW_GROUP_DATA_API_PARAMS.resource}`;

const endPoint = {
postingReview: `${process.env.API_BASE_URL}/${VERSION2}/reviews`,
postingReview: `${serverUrl}/${VERSION2}/reviews`,
gettingDetailedReview: (reviewId: number, reviewRequestCode: string) =>
`${DETAILED_REVIEW_API_URL}/${reviewId}?${DETAILED_REVIEW_API_PARAMS.queryString.reviewRequestCode}=${reviewRequestCode}`,
gettingDataToWriteReview: (reviewRequestCode: string) =>
`${REVIEW_WRITING_API_URL}/${REVIEW_WRITING_API_PARAMS.queryString.write}?${REVIEW_WRITING_API_PARAMS.queryString.reviewRequestCode}=${reviewRequestCode}`,
gettingReviewList: (reviewRequestCode: string) =>
`${REVIEW_LIST_API_URL}?${REVIEW_LIST_API_PARAMS.queryString.reviewRequestCode}=${reviewRequestCode}`,
postingDataForReviewRequestCode: `${process.env.API_BASE_URL}/${VERSION2}/groups`,
checkingPassword: `${process.env.API_BASE_URL}/${VERSION2}/${REVIEW_PASSWORD_API_PARAMS.resource}/${REVIEW_PASSWORD_API_PARAMS.queryString.check}`,
postingDataForReviewRequestCode: `${serverUrl}/${VERSION2}/groups`,
checkingPassword: `${serverUrl}/${VERSION2}/${REVIEW_PASSWORD_API_PARAMS.resource}/${REVIEW_PASSWORD_API_PARAMS.queryString.check}`,
gettingReviewGroupData: (reviewRequestCode: string) =>
`${REVIEW_GROUP_DATA_API_URL}?${REVIEW_GROUP_DATA_API_PARAMS.queryString.reviewRequestCode}=${reviewRequestCode}`,
};
Expand Down

0 comments on commit 489d0d7

Please sign in to comment.