Skip to content

Commit

Permalink
[FE] ♻️ 토큰 관련 불필요한 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
shimdokite committed May 6, 2024
1 parent a1ed884 commit cb5fa29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
9 changes: 3 additions & 6 deletions client/src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import axios, { AxiosResponse } from 'axios';

import LocalStorage from './localStorage';

import checkForToken from '@/utils/checkForToken';
import LocalStorage from '@/utils/localStorage';

const { authVerify, storageData } = checkForToken();

const accessToken =
typeof window !== 'undefined' ? storageData.state.accessToken : null;
const refreshToken =
typeof window !== 'undefined' ? storageData.state.refreshToken : null;
const accessToken = storageData?.state.accessToken;
const refreshToken = storageData?.state.refreshToken;

export const instance = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_URL,
Expand Down
8 changes: 3 additions & 5 deletions client/src/utils/checkForToken.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import LocalStorage from '@/api/localStorage';
import LocalStorage from './localStorage';

const checkForToken = () => {
const storageData = LocalStorage.getItem('user-key');

const accessToken =
typeof window !== 'undefined' ? storageData.state.accessToken : null;
const refreshToken =
typeof window !== 'undefined' ? storageData.state.refreshToken : null;
const accessToken = storageData?.state.accessToken;
const refreshToken = storageData?.state.refreshToken;

const parseJWT = (token: string | null) => {
if (token) return JSON.parse(atob(token.split('.')[1]));
Expand Down

0 comments on commit cb5fa29

Please sign in to comment.