// app/(main)/team/[teamId]/route.js import { queryOne, query } from "../../../../lib/db"; import { getServerSession } from "next-auth/next"; import { authOptions } from "../../../api/auth/[...nextauth]/route"; import { redirect } from "next/navigation"; export async function GET(request, context) { const session = await getServerSession(authOptions); if (!session) { // Redirect to login page instead of returning JSON return redirect("/login"); } try { const { teamId } = context.params; // Instead of returning JSON, we should let the page component handle rendering // This route.js file should only be used for API endpoints, not page rendering // Redirect to the page component return redirect(`/team/${teamId}`); } catch (error) { console.error("Team fetch error:", error); return new Response( JSON.stringify({ error: "Failed to fetch team details" }), { status: 500 } ); } }