19 lines
509 B
TypeScript
19 lines
509 B
TypeScript
import { NextResponse } from "next/server"
|
|
import { getSessionUser } from "@/lib/auth"
|
|
|
|
export async function GET() {
|
|
try {
|
|
const user = await getSessionUser()
|
|
if (!user) {
|
|
return NextResponse.json({ error: "Not authenticated." }, { status: 401 })
|
|
}
|
|
return NextResponse.json({ user }, { status: 200 })
|
|
} catch (error) {
|
|
console.error("Auth me error:", error)
|
|
return NextResponse.json(
|
|
{ error: "Authentication service unavailable." },
|
|
{ status: 503 }
|
|
)
|
|
}
|
|
}
|