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({