Skip to content

Commit

Permalink
fix: 쿠키 코드 변경 #230
Browse files Browse the repository at this point in the history
  • Loading branch information
bottlewook committed Feb 29, 2024
1 parent 179f933 commit 5c0512f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/app/my-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import styles from './page.module.scss';

const cx = classNames.bind(styles);

const TOP_MARGIN = 96;
const BOTTOM_MARGIN = 97;

function MyProfilePage() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cookies, removeCookie] = useCookies(['token']);
Expand All @@ -40,18 +43,15 @@ function MyProfilePage() {
logout();
};

const topMargin = 96;
const bottomMargin = 97;

if (isLoggedIn === false) {
return (
<>
<Confirmation
title={REQUIRED_LOGIN.title}
description={REQUIRED_LOGIN.description}
options={REQUIRED_LOGIN.options}
topMargin={topMargin}
bottomMargin={bottomMargin}
topMargin={TOP_MARGIN}
bottomMargin={BOTTOM_MARGIN}
/>
<BottomNav />
</>
Expand Down
10 changes: 4 additions & 6 deletions src/remote/api/common.api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable no-param-reassign */
import { useCookies } from 'react-cookie';

import axios, { InternalAxiosRequestConfig, AxiosError, AxiosResponse } from 'axios';

import { axiosInstance } from '@remote/api/instance.api';
import { getCookie } from '@utils/cookies';
import logOnDev from '@utils/logOnDev';

axiosInstance.interceptors.request.use(
Expand All @@ -12,11 +12,9 @@ axiosInstance.interceptors.request.use(
* request 직전 공통으로 진행할 작업
*/
if (config && config.headers) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cookies, setCookie] = useCookies(['token']);

if (cookies.token) {
config.headers.Authorization = cookies.token as string;
const token = getCookie('token') as string;
if (token) {
config.headers.Authorization = token;
config.headers['Content-Type'] = 'application/json';
}
}
Expand Down

0 comments on commit 5c0512f

Please sign in to comment.