From 55fd68de0fd00810b92bb71534e3cec20065994e Mon Sep 17 00:00:00 2001 From: ttaerrim Date: Thu, 23 Nov 2023 23:04:34 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20axios=20=EC=9D=B8=EC=8A=A4?= =?UTF-8?q?=ED=84=B4=EC=8A=A4=20header=EC=97=90=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/frontend/src/services/morakAPI.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/frontend/src/services/morakAPI.ts b/app/frontend/src/services/morakAPI.ts index e8b3548cb..e3a2da9f6 100644 --- a/app/frontend/src/services/morakAPI.ts +++ b/app/frontend/src/services/morakAPI.ts @@ -1,8 +1,17 @@ import axios from 'axios'; import { URL } from '@/constants'; +import { getCookies } from '@/utils'; + +const initialHeaders = { + 'Content-Type': 'application/json', + Accept: 'application/json', +}; +const headers = getCookies('access_token') + ? { ...initialHeaders, Authorization: `Bearer ${getCookies('access_token')}` } + : initialHeaders; export const morakAPI = axios.create({ baseURL: import.meta.env.DEV ? '' : URL.API, - headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, + headers, }); From 98e9b0430bc2facbbf93c95816f06fc9af48c36d Mon Sep 17 00:00:00 2001 From: ttaerrim Date: Thu, 23 Nov 2023 23:08:13 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EB=B2=84=ED=8A=BC=20=EB=A0=8C=EB=8D=94=EB=A7=81?= =?UTF-8?q?=EC=9D=98=20=EC=9C=A0=EB=AC=B4=EB=A5=BC=20=EC=BF=A0=ED=82=A4?= =?UTF-8?q?=EB=A1=9C=20=ED=8C=90=EB=8B=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/frontend/src/pages/Main/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/frontend/src/pages/Main/index.tsx b/app/frontend/src/pages/Main/index.tsx index 1f801a314..fe0b9ac8a 100644 --- a/app/frontend/src/pages/Main/index.tsx +++ b/app/frontend/src/pages/Main/index.tsx @@ -1,7 +1,7 @@ import { ReactComponent as GoogleIcon } from '@/assets/icons/google.svg'; import { Button } from '@/components'; import { MAIN_IMAGE, URL } from '@/constants'; -import { useUserAtom } from '@/stores'; +import { getCookies } from '@/utils'; import * as styles from './index.css'; @@ -9,7 +9,8 @@ export function Main() { const onClickGoogleLogin = () => { window.location.href = `${URL.API}/auth/google/login`; }; - const [user] = useUserAtom(); + + const isLogin = getCookies('access_token'); return (
@@ -22,7 +23,7 @@ export function Main() { 모락과 함께하세요
- {!user && ( + {!isLogin && (