From 3a89ee196b4ef921c1054e9af3b3bb00d5b1cc73 Mon Sep 17 00:00:00 2001 From: "j._.jinoo" Date: Sun, 7 Jul 2024 02:18:52 +0900 Subject: [PATCH 1/9] =?UTF-8?q?design=20:=20404=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EB=94=94=EC=9E=90=EC=9D=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/not-found.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 687e236..5cc6cba 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -8,7 +8,7 @@ const mont = Montserrat({ subsets: ['latin'], weight: ['500'] }); export default function Notfound() { return ( -
+
- -

- 이전으로 -

-

메인으로 From e77fa96d23ef1d3f0b2e0c81b40e9ea5244dbfe8 Mon Sep 17 00:00:00 2001 From: "j._.jinoo" Date: Sun, 7 Jul 2024 02:19:49 +0900 Subject: [PATCH 2/9] =?UTF-8?q?file=20:=20=EC=8B=A4=EC=88=98=EB=A1=9C=20?= =?UTF-8?q?=EC=84=9C=EB=B8=8C=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=9C=EA=B1=B0=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Github-Study | 1 - 1 file changed, 1 deletion(-) delete mode 160000 Github-Study diff --git a/Github-Study b/Github-Study deleted file mode 160000 index d42b139..0000000 --- a/Github-Study +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d42b1392bd67c712c744077a87109b3bfb544a42 From 1d3414fb9f335b7fd20fcdb9d37195826a81d574 Mon Sep 17 00:00:00 2001 From: "j._.jinoo" Date: Sun, 7 Jul 2024 05:02:16 +0900 Subject: [PATCH 3/9] =?UTF-8?q?feat=20:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=EC=9D=B4=20=EB=90=98=EC=96=B4=EC=9E=88=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EC=9C=BC=EB=A9=B4=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EB=A1=9C=20=EB=84=98=EC=96=B4=EA=B0=80?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/axios.config.ts | 35 +++++++++++++++++++---------------- src/api/nearMeeting.ts | 2 +- src/app/components/Header.tsx | 6 +++++- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/api/axios.config.ts b/src/api/axios.config.ts index df41e09..5b16020 100644 --- a/src/api/axios.config.ts +++ b/src/api/axios.config.ts @@ -1,3 +1,4 @@ +/* eslint-disable consistent-return */ /* eslint-disable no-underscore-dangle */ import axios from 'axios'; import { getCookie, setCookie } from '@/app/cookies.tsx'; @@ -10,12 +11,12 @@ const reIssuedToken = async () => { const response = await axios.post( `${BASE_URL}/reissue`, { - access_token: getCookie('accessToken'), // 액세스 토큰을 사용하고 있으나, 일반적으로는 사용하지 않습니다. - refresh_token: getCookie('refreshToken'), // 리프레시 토큰 + access_token: getCookie('accessToken'), + refresh_token: getCookie('refreshToken'), }, { headers: { - 'Content-Type': 'application/json', // 요청의 본문 타입을 지정 + 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}`, }, withCredentials: true, // CORS 요청 시 쿠키를 포함 @@ -45,22 +46,24 @@ const api = axios.create({ api.interceptors.response.use( (response) => response, // 성공 응답은 그대로 반환 async (error) => { - const originalRequest = error.config; - if (error.response.status === 401 && !originalRequest._retry) { - originalRequest._retry = true; // 재요청 플래그를 설정하여 무한 루프 방지 - try { - const data = await reIssuedToken(); // 토큰 재발급 함수 호출 - // 재발급 받은 토큰으로 요청 헤더 설정 - api.defaults.headers.common.Authorization = `Bearer ${data.data.access_token}`; - originalRequest.headers.Authorization = `Bearer ${data.data.access_token}`; + if (accessToken !== undefined) { + const originalRequest = error.config; + if (error.response.status === 401 && !originalRequest._retry) { + originalRequest._retry = true; // 재요청 플래그를 설정하여 무한 루프 방지 + try { + const data = await reIssuedToken(); // 토큰 재발급 함수 호출 + // 재발급 받은 토큰으로 요청 헤더 설정 + api.defaults.headers.common.Authorization = `Bearer ${data.data.access_token}`; + originalRequest.headers.Authorization = `Bearer ${data.data.access_token}`; - return api(originalRequest); // 원래 요청 재시도 - } catch (refreshError) { - return Promise.reject(refreshError); + return api(originalRequest); // 원래 요청 재시도 + } catch (refreshError) { + return Promise.reject(refreshError); + } } - } - return Promise.reject(error); + return Promise.reject(error); + } }, ); diff --git a/src/api/nearMeeting.ts b/src/api/nearMeeting.ts index c8f4524..cad71e3 100644 --- a/src/api/nearMeeting.ts +++ b/src/api/nearMeeting.ts @@ -13,7 +13,7 @@ const searchMeetings = async ( ); return response.data; } catch (error) { - throw new Error('meeting search api request error : ', error || ''); + throw new Error('주변 모임 검색 에러 : ', error || ''); } }; diff --git a/src/app/components/Header.tsx b/src/app/components/Header.tsx index 38554f7..f885f0b 100644 --- a/src/app/components/Header.tsx +++ b/src/app/components/Header.tsx @@ -8,7 +8,7 @@ import category from '@/util/category.json'; import { useQuery } from '@tanstack/react-query'; import { login, logout } from '@/api/user.ts'; import ignorePath from '../styles/ignorePath.ts'; -import { removeCookie } from '../cookies.tsx'; +import { getCookie, removeCookie } from '../cookies.tsx'; const mont = Montserrat({ subsets: ['latin'], weight: ['500'] }); @@ -25,6 +25,10 @@ function Header() { queryFn: login, }); + if (!getCookie('accessToken') && !getCookie('refreshToken')) { + router.push('/login'); + } + if (ignorePath().includes(path)) { return null; } From 126103e7da76eb4e7c118148496fb7f3b7cd5f20 Mon Sep 17 00:00:00 2001 From: "j._.jinoo" Date: Sun, 7 Jul 2024 05:07:59 +0900 Subject: [PATCH 4/9] =?UTF-8?q?fix=20:=20=EC=A7=80=EB=8F=84=EB=A5=BC=20?= =?UTF-8?q?=EB=B6=88=EB=9F=AC=EC=98=A4=EC=A7=80=20=EB=AA=BB=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/Header.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/components/Header.tsx b/src/app/components/Header.tsx index f885f0b..c38a8e7 100644 --- a/src/app/components/Header.tsx +++ b/src/app/components/Header.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { Montserrat } from 'next/font/google'; import Link from 'next/link'; import { usePathname, useRouter } from 'next/navigation'; @@ -25,9 +25,15 @@ function Header() { queryFn: login, }); - if (!getCookie('accessToken') && !getCookie('refreshToken')) { - router.push('/login'); - } + const checkAuthentication = async () => { + if (!getCookie('accessToken') && !getCookie('refreshToken')) { + await router.push('/login'); + } + }; + + useEffect(() => { + checkAuthentication(); + }, []); if (ignorePath().includes(path)) { return null; From 3a5e84c96a5296b6da72d6127e8c7b343a34ad3f Mon Sep 17 00:00:00 2001 From: "j._.jinoo" Date: Sun, 7 Jul 2024 05:22:09 +0900 Subject: [PATCH 5/9] =?UTF-8?q?feat=20:=20Loading=EC=9D=B4=20=EB=82=98?= =?UTF-8?q?=EC=98=A4=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0=20?= =?UTF-8?q?=EB=B0=8F=20stores=EC=97=90=EB=9F=AC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/home/Body.tsx | 47 +++++++++++++++++++++---------------------- src/app/layout.tsx | 18 ++++++++--------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/app/home/Body.tsx b/src/app/home/Body.tsx index 319bfe5..fbcdb95 100644 --- a/src/app/home/Body.tsx +++ b/src/app/home/Body.tsx @@ -50,29 +50,28 @@ function Distance() { const renderSize = 8; - const { data, fetchNextPage, hasNextPage, isFetchingNextPage } = - useInfiniteQuery({ - queryKey: ['Latest Meeting List', latitude, longitude], - queryFn: async ({ pageParam = 0 }) => { - if (latitude !== null && longitude !== null) { - return searchMeetings( - latitude, - longitude, - pageParam, - renderSize, - 'asc', - ); - } - }, - getNextPageParam: (lastPage, allPages) => { - if (lastPage === null) { - return undefined; - } - return allPages.length; - }, - enabled: locationFetched, // 위치 정보를 성공적으로 가져왔을 때만 쿼리 실행 - initialPageParam: 0, - }); + const { data, fetchNextPage, hasNextPage } = useInfiniteQuery({ + queryKey: ['Latest Meeting List', latitude, longitude], + queryFn: async ({ pageParam = 0 }) => { + if (latitude !== null && longitude !== null) { + return searchMeetings( + latitude, + longitude, + pageParam, + renderSize, + 'asc', + ); + } + }, + getNextPageParam: (lastPage, allPages) => { + if (lastPage === null) { + return undefined; + } + return allPages.length; + }, + enabled: locationFetched, // 위치 정보를 성공적으로 가져왔을 때만 쿼리 실행 + initialPageParam: 0, + }); const loadMoreRef = useRef(null); @@ -260,7 +259,7 @@ function Distance() { ), ), )} - {isFetchingNextPage &&

Loading...
} + {/* {isFetchingNextPage &&
Loading...
} */}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 12db98f..afaabcc 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,7 +3,7 @@ import type { Metadata } from 'next'; import { Inter } from 'next/font/google'; import './styles/globals.css'; import Script from 'next/script'; -import StoreProvider from './StoreProvider.tsx'; +// import StoreProvider from './StoreProvider.tsx'; import Header from './components/Header.tsx'; import Footer from './components/Footer.tsx'; import QueryProviders from '../lib/QueryProvider.tsx'; @@ -31,14 +31,14 @@ export default function RootLayout({ 로딩중인데요?ㅋㅋ
}>
- - -
{children}
-
+ {/* */} + +
{children}
+ {/*
*/}