From 9e4ae46fddb7b71f0ccdfdc12421b481356180af Mon Sep 17 00:00:00 2001 From: yyypearl Date: Thu, 23 May 2024 17:10:30 +0900 Subject: [PATCH] =?UTF-8?q?fix(#96):=20localStorage=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/axios.ts | 9 +++++++-- src/app/signin/process4/page.tsx | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/apis/axios.ts b/src/apis/axios.ts index d821d20..1fe7f7e 100644 --- a/src/apis/axios.ts +++ b/src/apis/axios.ts @@ -1,11 +1,16 @@ import axios from "axios"; -const accessToken = localStorage.getItem("access_token"); +const getToken = () => { + if (typeof window !== "undefined") { + return localStorage.getItem("access_token"); + } + return null; +}; const Axios = axios.create({ baseURL: process.env.NEXT_PUBLIC_BASE_URL, headers: { - Authorization: `Bearer ${accessToken}`, + Authorization: `Bearer ${getToken()}`, "Content-Type": "application/json;charset=UTF-8", }, }); diff --git a/src/app/signin/process4/page.tsx b/src/app/signin/process4/page.tsx index 920a2b2..15d2d6d 100644 --- a/src/app/signin/process4/page.tsx +++ b/src/app/signin/process4/page.tsx @@ -56,7 +56,9 @@ const SigninProcess4 = () => { }; const data = await postUser(User); - localStorage.setItem("access_token", data.accessToken); + if (typeof window !== "undefined") { + localStorage.setItem("access_token", data.accessToken); + } dispatch( setToken({