From 023faafd7cd6570316274beea4a106a73742a796 Mon Sep 17 00:00:00 2001 From: Junseo Kim Date: Sat, 21 Dec 2024 10:16:41 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20Axios=20=ED=81=B4=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EC=96=B8=ED=8A=B8=EC=97=90=20=ED=99=98=EA=B2=BD?= =?UTF-8?q?=EB=B3=80=EC=88=98=EB=A5=BC=20=ED=99=9C=EC=9A=A9=ED=95=9C=20bas?= =?UTF-8?q?eURL=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - REACT_APP_API_BASE_URL 환경변수를 사용하여 Axios 기본 URL(baseURL)을 동적으로 설정 - 로컬 개발 및 배포 환경별 API URL 변경을 쉽게 관리할 수 있도록 개선 - 기존 하드코딩된 URL 제거 --- client/src/api/apiClient.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/api/apiClient.ts b/client/src/api/apiClient.ts index 918e42e..168ec06 100644 --- a/client/src/api/apiClient.ts +++ b/client/src/api/apiClient.ts @@ -1,9 +1,11 @@ import axios from 'axios'; import Cookies from 'js-cookie'; +const apiBaseUrl = process.env.REACT_APP_API_BASE_URL; + // Axios 클라이언트 생성 const apiClient = axios.create({ - baseURL: 'http://34.64.179.51:8080/api', // 기본 API URL 설정 + baseURL: apiBaseUrl, // 기본 API URL 설정 }); // 요청 인터셉터 From 5f6e6e78a97d8210f11b061de67ab4eeeabd98f1 Mon Sep 17 00:00:00 2001 From: Junseo Kim Date: Sat, 21 Dec 2024 10:16:48 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=EC=97=90=20=ED=99=98=EA=B2=BD=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=A5=BC=20=ED=99=9C=EC=9A=A9=ED=95=9C=20API=20URL=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - REACT_APP_API_BASE_URL 환경변수를 사용하여 로그인 API URL을 설정 - 하드코딩된 URL을 제거하고 환경별 설정 가능하도록 개선 - 유지보수성과 배포 환경의 유연성 향상 --- client/src/api/logIn.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/api/logIn.ts b/client/src/api/logIn.ts index 0f234b0..ecfc301 100644 --- a/client/src/api/logIn.ts +++ b/client/src/api/logIn.ts @@ -14,6 +14,9 @@ interface RegisterResponse { data: LoginData; } +// 환경변수에서 API URL 가져오기 +const API_BASE_URL = process.env.REACT_APP_API_BASE_URL; + // 토큰 가져오기 함수 추가 export const getAccessToken = (): string | null => { return localStorage.getItem('accessToken'); @@ -54,7 +57,7 @@ export const logIn = async ( try { // 로그인 API 호출 const response = await axios.post( - 'http://34.64.179.51:8080/auth/admins/login', + `${API_BASE_URL}/auth/admins/login`, // 환경변수를 사용한 API URL { name: name, password: password, From d0d7f184e578a45968f38941a26aa42dc0293dc1 Mon Sep 17 00:00:00 2001 From: Junseo Kim Date: Sat, 21 Dec 2024 10:16:55 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=ED=95=A8=EC=88=98=EC=97=90=EC=84=9C=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EB=B3=80=EC=88=98=EB=A5=BC=20=ED=99=9C=EC=9A=A9?= =?UTF-8?q?=ED=95=9C=20API=20URL=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - REACT_APP_API_BASE_URL 환경변수를 사용하여 회원가입 API URL을 설정 - 코드의 가독성과 유지보수성을 높이기 위해 하드코딩된 URL 제거 - 배포 환경별 유연한 API URL 관리 가능 --- client/src/api/signUp.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/api/signUp.ts b/client/src/api/signUp.ts index 81780ee..2d6554c 100644 --- a/client/src/api/signUp.ts +++ b/client/src/api/signUp.ts @@ -1,12 +1,16 @@ import axios, {AxiosResponse} from 'axios'; +// 환경변수에서 API URL 가져오기 +const API_BASE_URL = process.env.REACT_APP_API_BASE_URL; + +// 회원가입 함수 export const signUp = ( name: string, password: string, email: string, ): Promise => { return axios - .post('http://34.64.179.51:8080/auth/admins/register', { + .post(`${API_BASE_URL}/auth/admins/register`, { name: name, password: password, email: email, @@ -15,7 +19,7 @@ export const signUp = ( return res; }) .catch(error => { - console.log('Failed to register admin:', error); + console.error('Failed to register admin:', error); return null; }); };