Skip to content

Commit a896b99

Browse files
committed
fix : 수정
1 parent 8d35141 commit a896b99

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

frontend/src/api/client.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
const BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:8080";
22

3+
// 토큰이 필요 없는 공개 엔드포인트
4+
const publicEndpoints = [
5+
"/channel/find/all",
6+
"/channel/find/keyword",
7+
"/hobby/find/all",
8+
];
9+
310
export const client = async (endpoint: string, options: RequestInit = {}) => {
411
const url = `${BASE_URL}${endpoint}`;
512

6-
// /auth 경로 중 current-user는 토큰 필요
7-
const requiresAuth = !endpoint.startsWith("/auth") || endpoint === "/auth/find/current-user";
13+
// /auth 경로 중 current-user는 토큰 필요, 공개 엔드포인트는 토큰 불필요
14+
const isPublicEndpoint = publicEndpoints.some(pe => endpoint.startsWith(pe));
15+
const requiresAuth = (!endpoint.startsWith("/auth") || endpoint === "/auth/find/current-user") && !isPublicEndpoint;
816
const token = requiresAuth ? localStorage.getItem("token") : null;
917

1018
console.log(`API Request: ${endpoint}, requiresAuth: ${requiresAuth}, hasToken: ${token ? 'Yes' : 'No'}, tokenValue: ${token?.substring(0, 30)}...`);

0 commit comments

Comments
 (0)