diff --git a/src/main.tsx b/src/main.tsx index 5cf59cb8..ef2936b2 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2,7 +2,6 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import '@/globals.css'; import MainRouter from '@routes/MainRouter.tsx'; -import { CookiesProvider } from 'react-cookie'; async function enableMocking() { if (!import.meta.env.DEV) return; @@ -14,9 +13,7 @@ async function enableMocking() { enableMocking().then(() => { ReactDOM.createRoot(document.getElementById('root')!).render( - - - + , ); }); diff --git a/src/mocks/services/authServiceHandler.ts b/src/mocks/services/authServiceHandler.ts index f0e2c887..f93ff272 100644 --- a/src/mocks/services/authServiceHandler.ts +++ b/src/mocks/services/authServiceHandler.ts @@ -25,6 +25,23 @@ const authServiceHandler = [ } return new HttpResponse(JSON.stringify({ message: '아이디 또는 비밀번호가 잘못되었습니다.' }), { status: 400 }); }), + // refresh token 갱신 API + http.post(`${BASE_URL}/user/login/refresh`, async ({ cookies }) => { + const { refreshToken } = cookies; + + if (refreshToken === 'mockedRefreshToken') { + const newAccessToken = 'newMockedAccessToken'; + + return new HttpResponse(null, { + status: 200, + headers: { + Authorization: `Bearer ${newAccessToken}`, + 'Set-Cookie': `refreshToken=${refreshToken}`, + }, + }); + } + return new HttpResponse(JSON.stringify({ message: '리프레시 토큰이 유효하지 않습니다.' }), { status: 400 }); + }), ]; export default authServiceHandler;