Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 460e031

Browse files
committed
fix: Update cookie handling in logout and dashboard components
- Refactor logout route to use await for cookie deletion. - Update dashboard component to await cookie retrieval for session management.
1 parent bc91308 commit 460e031

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/api/auth/logout/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { cookies } from "next/headers"
33

44
export async function GET(request: NextRequest) {
55
// 清除会话 Cookie
6-
cookies().delete("session")
6+
const cookieStore = await cookies()
7+
cookieStore.delete("session")
78

89
// 重定向到首页
910
return NextResponse.redirect(new URL("/", request.url))

app/dashboard/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { Button } from "@/components/ui/button"
55
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
66
import Link from "next/link"
77

8-
export default function Dashboard() {
8+
export default async function Dashboard() {
99
// 获取会话 Cookie
10-
const cookieStore = cookies()
10+
const cookieStore = await cookies()
1111
const sessionCookie = cookieStore.get("session")
1212

1313
if (!sessionCookie) {

0 commit comments

Comments
 (0)