From 712d7de08970b6eb728796a254c0072d12d3338e Mon Sep 17 00:00:00 2001 From: Yangseungchan Date: Sat, 1 Jul 2023 21:05:58 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EC=9A=B0=ED=9A=8C=EB=B0=A9=EB=B2=95=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 --- next.config.js | 17 +++++++++++++---- src/app/login/api/login.ts | 3 ++- src/app/login/hooks/useLogin/useLogin.ts | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/next.config.js b/next.config.js index 7580dbb7..572bb23b 100644 --- a/next.config.js +++ b/next.config.js @@ -11,13 +11,22 @@ const nextConfig = { // 프록시 설정 async rewrites(){ const API_ENDPOINT = process.env.API_URL ?? process.env.NEXT_PUBLIC_API_URL; - return process.env.NODE_ENV === 'development' ? [ + + const rewriteTargets = [ { + source: '/api/login', + destination: `${API_ENDPOINT}/v1/users/login` + }, + ] + + if(process.env.NODE_ENV === 'development') { + rewriteTargets.push({ source: '/api/:path*', destination: `${API_ENDPOINT}/:path*`, - } - ] : []; - + }); + } + + return rewriteTargets; } } diff --git a/src/app/login/api/login.ts b/src/app/login/api/login.ts index e762689e..e601d7ec 100644 --- a/src/app/login/api/login.ts +++ b/src/app/login/api/login.ts @@ -3,7 +3,8 @@ import { LoginRequest, LoginResponse } from '../types/login'; export const postLogin = async ({ email, password, keep }: LoginRequest): Promise => { const result = await request - .post('v1/users/login', { + .post('/api/login', { + prefixUrl: '', json: { email, password, diff --git a/src/app/login/hooks/useLogin/useLogin.ts b/src/app/login/hooks/useLogin/useLogin.ts index 19ca4d65..ab7167a8 100644 --- a/src/app/login/hooks/useLogin/useLogin.ts +++ b/src/app/login/hooks/useLogin/useLogin.ts @@ -13,7 +13,8 @@ export const useLogin = (): UseMutationResult(postLogin, { + const loginMutation = useMutation({ + mutationFn: postLogin, onSuccess: handleLoginSuccess, onError: handleLoginError, }); From 7b8a73a26cdd7137bc7df996b34ba4897ef918f9 Mon Sep 17 00:00:00 2001 From: Yangseungchan Date: Sun, 2 Jul 2023 13:26:26 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20profile=20=EA=B4=80=EB=A0=A8=20cac?= =?UTF-8?q?he=20=EC=98=B5=EC=85=98=20=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user/api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/user/api.ts b/src/api/user/api.ts index bfca5368..89f6ec02 100644 --- a/src/api/user/api.ts +++ b/src/api/user/api.ts @@ -4,7 +4,11 @@ import { request } from '@/utils/ky/request'; class UserAPI { /** 로그인한 유저의 프로필을 조회합니다 */ async getProfile() { - return request.get('v1/users/profile').json(); + return request + .get('v1/users/profile', { + cache: 'no-store', + }) + .json(); } }