import { NextResponse } from "next/server"; import { errorToResponse } from "@kri/common/http"; import { createServerApi } from "@/lib/http-server"; import { isLoginUser } from "@/types/kart"; export async function GET(_request: Request, context: { params: Promise<{ slug?: string[] }> }) { const { slug = [] } = await context.params; if (slug.length !== 1 || slug[0] !== "my-info") return NextResponse.json({ message: "Not found" }, { status: 404, headers: { "Cache-Control": "no-store" } }); try { const api = await createServerApi(); const user = await api.get("/auth/my-info", { cache: "no-store" }); if (!isLoginUser(user)) { return NextResponse.json({ message: "Invalid user response" }, { status: 502, headers: { "Cache-Control": "no-store" } }); } return NextResponse.json({ userId: user.userId, userName: user.userName, userCmpn: user.userCmpn, userTeam: user.userTeam, userRole: user.userRole }, { headers: { "Cache-Control": "no-store" } }); } catch (error) { const response = errorToResponse(error); response.headers.set("Cache-Control", "no-store"); return response; } }