Skip to content

Commit

Permalink
Merge pull request #56 from Kusitms-29th-ASAP/fix/#46
Browse files Browse the repository at this point in the history
[Fix] Deploy 오류 - window 객체 예외처리
  • Loading branch information
yyypearl authored May 18, 2024
2 parents cdc0499 + efdaca1 commit 4002e00
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions src/app/auth/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,40 @@ const Auth = () => {
);

useEffect(() => {
const ACCESS_TOKEN = localStorage.getItem("access_token");
postKakaoToken(ACCESS_TOKEN!!);
if (typeof window !== "undefined") {
const ACCESS_TOKEN = localStorage.getItem("access_token");
postKakaoToken(ACCESS_TOKEN!!);

const getToken = async () => {
const res = axios.post(
"https://kauth.kakao.com/oauth/token",
{
grant_type: "authorization_code",
client_id: REST_API_KEY,
redirect_uri: REDIRECT_URI,
code: AUTHORIZATION_CODE,
},
{
headers: {
"Content-Type": "application/x-www-form-urlencoded",
const getToken = async () => {
const res = axios.post(
"https://kauth.kakao.com/oauth/token",
{
grant_type: "authorization_code",
client_id: REST_API_KEY,
redirect_uri: REDIRECT_URI,
code: AUTHORIZATION_CODE,
},
}
);
return res;
};
{
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
}
);
return res;
};

getToken()
.then((res) => {
if (res) {
localStorage.setItem(
"access_token",
JSON.stringify(res.data.access_token)
);
router.push("/signin/terms");
}
})
.catch((err) => console.log(err));
getToken()
.then((res) => {
if (res) {
localStorage.setItem(
"access_token",
JSON.stringify(res.data.access_token)
);
router.push("/signin/terms");
}
})
.catch((err) => console.log(err));
}
}, []);

return null;
Expand Down

0 comments on commit 4002e00

Please sign in to comment.