diff --git a/app/api/auth/check/route.ts b/app/api/auth/check/route.ts index 351c3ca..e2ddca2 100644 --- a/app/api/auth/check/route.ts +++ b/app/api/auth/check/route.ts @@ -1,5 +1,8 @@ import { NextRequest, NextResponse } from 'next/server'; +// This ensures this route is always handled at runtime and never prerendered +export const dynamic = 'force-dynamic'; + export async function GET(req: NextRequest) { try { // Check for Authorization in headers first, then fall back to cookies diff --git a/app/auth/login/page.tsx b/app/auth/login/page.tsx index e3724d3..088cbe5 100644 --- a/app/auth/login/page.tsx +++ b/app/auth/login/page.tsx @@ -1,6 +1,6 @@ "use client" -import { useState, useEffect } from "react"; +import { useState, useEffect, Suspense } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import Link from "next/link"; import { Button } from "@/components/ui/button"; @@ -8,7 +8,8 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { toast } from "sonner"; -export default function LoginPage() { +// Separate the main login functionality into a client component +function LoginForm() { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); @@ -131,4 +132,27 @@ export default function LoginPage() { ); +} + +// Simple loading state for the Suspense boundary +function LoginLoading() { + return ( +
Loading login form...
+