Skip to content

Commit 0ea5ec2

Browse files
committed
fix: /users/me 대신 /auth/me 엔드포인트 사용
1 parent daa134b commit 0ea5ec2

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/app/auth/callback/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useEffect, useRef, useState, Suspense } from "react"
44
import { useRouter } from "next/navigation"
55
import { useAuthStore } from "@/features/auth/store/auth-store"
66
import { apiClient, getErrorMessage } from "@/shared/lib/api-client"
7-
import { RegisterUserResponse } from "@/shared/types/api"
7+
import { getUser } from "@/features/user/api/user-service"
88
import { toast } from "sonner"
99
import { Card } from "@/shared/components/card"
1010
import { Button } from "@/shared/components/button"
@@ -43,8 +43,9 @@ function RedirectHandler() {
4343
if (hasCalledRef.current) return
4444
hasCalledRef.current = true
4545

46-
// 쿠키는 이미 Set-Cookie로 설정되어 있으므로, /users/me로 사용자 정보 조회
47-
apiClient.get<void, RegisterUserResponse>('/users/me')
46+
// 쿠키는 이미 Set-Cookie로 설정되어 있으므로, /auth/me로 사용자 식별 후 전체 정보 조회
47+
apiClient.get<void, { username: string }>('/auth/me')
48+
.then(({ username }) => getUser(username))
4849
.then((user) => {
4950
login(user)
5051
toast.success(`환영합니다, ${user.username}님!`)

src/app/oauth2/redirect/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useEffect, useRef, useState, Suspense } from "react"
44
import { useRouter } from "next/navigation"
55
import { useAuthStore } from "@/features/auth/store/auth-store"
66
import { apiClient, getErrorMessage } from "@/shared/lib/api-client"
7-
import { RegisterUserResponse } from "@/shared/types/api"
7+
import { getUser } from "@/features/user/api/user-service"
88
import { toast } from "sonner"
99
import { Card } from "@/shared/components/card"
1010
import { Button } from "@/shared/components/button"
@@ -43,8 +43,9 @@ function RedirectHandler() {
4343
if (hasCalledRef.current) return
4444
hasCalledRef.current = true
4545

46-
// 쿠키는 이미 Set-Cookie로 설정되어 있으므로, /users/me로 사용자 정보 조회
47-
apiClient.get<void, RegisterUserResponse>('/users/me')
46+
// 쿠키는 이미 Set-Cookie로 설정되어 있으므로, /auth/me로 사용자 식별 후 전체 정보 조회
47+
apiClient.get<void, { username: string }>('/auth/me')
48+
.then(({ username }) => getUser(username))
4849
.then((user) => {
4950
login(user)
5051
toast.success(`환영합니다, ${user.username}님!`)

src/shared/providers/auth-provider.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useEffect, useRef } from "react"
44
import { useAuthStore } from "@/features/auth/store/auth-store"
55
import { apiClient } from "@/shared/lib/api-client"
6-
import { RegisterUserResponse } from "@/shared/types/api"
6+
import { getUser } from "@/features/user/api/user-service"
77

88
export function AuthProvider({ children }: { children: React.ReactNode }) {
99
const { isAuthenticated, user, login, logout } = useAuthStore()
@@ -17,7 +17,9 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
1717

1818
const verifyAuth = async () => {
1919
try {
20-
const freshUser = await apiClient.get<void, RegisterUserResponse>(`/users/${user.username}`)
20+
// /auth/me로 쿠키 유효성 확인 후 전체 사용자 정보 조회
21+
const me = await apiClient.get<void, { username: string }>('/auth/me')
22+
const freshUser = await getUser(me.username)
2123
login(freshUser)
2224
} catch {
2325
if (process.env.NODE_ENV === "development") {

0 commit comments

Comments
 (0)