Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 로그아웃이 제대로 안되는 문제 해결 #393

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

HyeryongChoi
Copy link
Collaborator

📄 Summary

원인

import axios from 'axios';

import { Tokens } from '@/types/auth/client';
import { zipgoLocalStorage } from '@/utils/localStorage';

export const { BASE_URL } = process.env;

const tokens = zipgoLocalStorage.getTokens();

const defaultConfig = {
  baseURL: BASE_URL,
};

export const createConfigWithAuth = (tokens: Tokens | null) =>
  tokens
    ? Object.assign(defaultConfig, {
        headers: {
          Authorization: `Bearer ${tokens.accessToken}`,
        },
      })
    : defaultConfig;

export const clientBasic = axios.create(defaultConfig);

export const client = axios.create(createConfigWithAuth(tokens));

Object.assign으로 defaultConfig를 바꿔버려서 문제가 된 것!!

해결

export const createConfigWithAuth = (tokens: Tokens | null) =>
  tokens
    ? {
        ...defaultConfig,
        headers: {
          Authorization: `Bearer ${tokens.accessToken}`,
        },
      }
    : defaultConfig;

🙋🏻 More

@n0eyes
Copy link
Collaborator

n0eyes commented Sep 13, 2023

제가 한 실수를 해결해 주셔서 감사합니다 😂

Copy link
Collaborator

@iamjooon2 iamjooon2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫡

@HyeryongChoi HyeryongChoi merged commit 8bb303b into develop Sep 13, 2023
1 check passed
@iamjooon2 iamjooon2 deleted the fix/#392 branch September 13, 2023 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] 로그아웃이 제대로 안되는 문제
3 participants