diff --git a/src/app/(auth)/authorize/page.tsx b/src/app/(auth)/authorize/page.tsx
index 8dc4ce8..0c2ef71 100644
--- a/src/app/(auth)/authorize/page.tsx
+++ b/src/app/(auth)/authorize/page.tsx
@@ -23,7 +23,9 @@ export default function AuthPage({ searchParams }: Props) {
// 解码 OAuth 参数
const params = JSON.parse(atob(oauthState));
// 删除 cookie
- Cookies.remove("oauth_state", { path: "/" });
+ fetch("/api/auth/oauth-state", { method: "DELETE" }).catch(
+ console.error,
+ );
// 构建重定向 URL
const searchParams = new URLSearchParams(params);
router.push(`/oauth/authorize?${searchParams.toString()}`);
diff --git a/src/app/(auth)/sign-in/page.tsx b/src/app/(auth)/sign-in/page.tsx
index 0f5d72d..c7efe68 100644
--- a/src/app/(auth)/sign-in/page.tsx
+++ b/src/app/(auth)/sign-in/page.tsx
@@ -1,4 +1,6 @@
-import { Suspense } from "react";
+"use client";
+
+import { useEffect } from "react";
import { Metadata } from "next";
import Link from "next/link";
import { ChevronLeft, MessageCircleCode } from "lucide-react";
@@ -7,12 +9,29 @@ import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/button";
import { UserAuthForm } from "@/components/auth/user-auth-form";
+interface Props {
+ searchParams: { state?: string };
+}
+
export const metadata: Metadata = {
title: "Login",
description: "Login to your account",
};
-export default function LoginPage() {
+export default function LoginPage({ searchParams }: Props) {
+ useEffect(() => {
+ // 如果有 state 参数,保存到 cookie
+ if (searchParams.state) {
+ fetch("/api/auth/oauth-state", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ state: searchParams.state }),
+ }).catch(console.error);
+ }
+ }, [searchParams.state]);
+
return (
<>
Q58 Connect
-
By clicking continue, you agree to our{" "}