From 5bc7bea45b2545e14a1d14ba9ebce3c97afc967c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=A7=E1=86=BC?= Date: Fri, 15 Dec 2023 22:55:03 +0900 Subject: [PATCH 1/3] Chore : update build script --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ff4efb8..ed6264b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,7 @@ jobs: build: runs-on: ubuntu-20.04 env: + REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }} REACT_APP_NAVER_CLIENT_ID: ${{ secrets.NAVER_CLIENT_ID }} REACT_APP_NAVER_REDIRECT_URI: ${{ secrets.NAVER_REDIRECT_URI }} REACT_APP_KAKAO_CLIENT_ID: ${{ secrets.KAKAO_CLIENT_ID }} @@ -43,6 +44,7 @@ jobs: echo "REACT_APP_REGION=$REACT_APP_REGION" >> .env.production env: + REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }} REACT_APP_NAVER_CLIENT_ID: ${{ secrets.NAVER_CLIENT_ID }} REACT_APP_NAVER_REDIRECT_URI: ${{ secrets.NAVER_REDIRECT_URI }} REACT_APP_KAKAO_CLIENT_ID: ${{ secrets.KAKAO_CLIENT_ID }} From d750fd1145c5169a5356ce24821c7f56586947cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=A7=E1=86=BC?= Date: Fri, 15 Dec 2023 22:55:23 +0900 Subject: [PATCH 2/3] Feat : add login request --- src/api/hooks/useLogin.ts | 14 ++++++++++++++ src/component/home/KakaoOauth.tsx | 11 +++++++++++ src/component/home/NaverOauth.tsx | 11 +++++++++++ src/shared/axios.ts | 4 ++-- 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/api/hooks/useLogin.ts diff --git a/src/api/hooks/useLogin.ts b/src/api/hooks/useLogin.ts new file mode 100644 index 0000000..16f7536 --- /dev/null +++ b/src/api/hooks/useLogin.ts @@ -0,0 +1,14 @@ +import { useQuery } from 'react-query'; +import instance from 'shared/axios'; + +export const useLogin = (codeValue: string) => { + return useQuery( + ['login'], + async () => await instance.post(`/api/user/kakao?code=${codeValue}`), + { + onSuccess(data) { + return data; + }, + } + ); +}; diff --git a/src/component/home/KakaoOauth.tsx b/src/component/home/KakaoOauth.tsx index 8dee543..8e5c22b 100644 --- a/src/component/home/KakaoOauth.tsx +++ b/src/component/home/KakaoOauth.tsx @@ -1,9 +1,20 @@ +import { useEffect } from 'react'; import { useLocation } from 'react-router'; +import instance from 'shared/axios'; export default function KakaoOauth() { const location = useLocation(); const urlParams = new URLSearchParams(location.search); const codeValue = urlParams.get('code'); + const Login = async () => { + const response = await instance.post(`/api/user/kakao?code=${codeValue}`); + return response; + }; + + useEffect(() => { + console.log(Login()); + }, []); + return <>카카오 리다이렉트 페이지; } diff --git a/src/component/home/NaverOauth.tsx b/src/component/home/NaverOauth.tsx index 01ce972..95eb5ec 100644 --- a/src/component/home/NaverOauth.tsx +++ b/src/component/home/NaverOauth.tsx @@ -1,9 +1,20 @@ +import { useEffect } from 'react'; import { useLocation } from 'react-router'; +import instance from 'shared/axios'; export default function NaverOauth() { const location = useLocation(); const urlParams = new URLSearchParams(location.search); const codeValue = urlParams.get('code'); + const Login = async () => { + const response = await instance.post(`/api/user/naver?code=${codeValue}`); + return response; + }; + + useEffect(() => { + console.log(Login()); + }, []); + return <>네이버 리다이렉트 페이지; } diff --git a/src/shared/axios.ts b/src/shared/axios.ts index 27d283d..2248676 100644 --- a/src/shared/axios.ts +++ b/src/shared/axios.ts @@ -44,10 +44,10 @@ instance.interceptors.response.use( return axios(originalRequest); } if (response.status === 404) { - return window.location.replace('/notfound'); + // return window.location.replace('/notfound'); } if (response.status === 504) { - return window.location.replace('/connectfail'); + // return window.location.replace('/connectfail'); } if (response.status === 400) { return response; From e5ac0842009d24ebb684e72e1bb904debb2df411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=86=E1=85=B5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=A7=E1=86=BC?= Date: Fri, 15 Dec 2023 22:59:27 +0900 Subject: [PATCH 3/3] Fix : remove login hook --- src/api/hooks/useLogin.ts | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 src/api/hooks/useLogin.ts diff --git a/src/api/hooks/useLogin.ts b/src/api/hooks/useLogin.ts deleted file mode 100644 index 16f7536..0000000 --- a/src/api/hooks/useLogin.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { useQuery } from 'react-query'; -import instance from 'shared/axios'; - -export const useLogin = (codeValue: string) => { - return useQuery( - ['login'], - async () => await instance.post(`/api/user/kakao?code=${codeValue}`), - { - onSuccess(data) { - return data; - }, - } - ); -};