Skip to content

Commit

Permalink
Merge pull request #97 from Kusitms-29th-ASAP/feat/#96
Browse files Browse the repository at this point in the history
[Fix] localStorage 오류 수정
  • Loading branch information
yyypearl authored May 23, 2024
2 parents e1009e9 + 9e4ae46 commit 60106df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/apis/axios.ts
Original file line number Diff line number Diff line change
@@ -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",
},
});
Expand Down
4 changes: 3 additions & 1 deletion src/app/signin/process4/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 60106df

Please sign in to comment.