diff --git a/src/app/api/auth/logout/route.ts b/src/app/api/auth/logout/route.ts index ed24ebe..8a73281 100644 --- a/src/app/api/auth/logout/route.ts +++ b/src/app/api/auth/logout/route.ts @@ -3,11 +3,12 @@ import { cookies } from 'next/headers' export async function POST() { const cookieStore = await cookies() + const domain = process.env.COOKIE_DOMAIN || '' - // 清除所有相关 cookie - cookieStore.set('tlyq_session', '', { maxAge: 0, path: '/' }) - cookieStore.set('session', '', { maxAge: 0, path: '/' }) - cookieStore.set('oidc_id_token', '', { maxAge: 0, path: '/' }) + // 清除所有相关 cookie(必须指定 domain 以清除跨域 cookie) + cookieStore.set('tlyq_session', '', { maxAge: 0, path: '/', domain }) + cookieStore.set('session', '', { maxAge: 0, path: '/', domain }) + cookieStore.set('oidc_id_token', '', { maxAge: 0, path: '/', domain }) // Authelia 4.38 不支持 end_session_endpoint,直接跳转登录页 // Authelia session 会在 cookie 过期后自动清除 diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index aa5cbb0..d3a1db0 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -1,9 +1,9 @@ 'use client' -import { useState } from 'react' +import { useState, Suspense } from 'react' import { useSearchParams } from 'next/navigation' -export default function LoginPage() { +function LoginPageContent() { const [username, setUsername] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') @@ -86,3 +86,11 @@ export default function LoginPage() { ) } + +export default function LoginPage() { + return ( + 加载中...}> + + + ) +}