19 lines
387 B
TypeScript
19 lines
387 B
TypeScript
|
'use server';
|
||
|
|
||
|
import { NextResponse } from "next/server";
|
||
|
import { getServerSession } from "next-auth";
|
||
|
import { authOptions } from "@/app/lib/auth";
|
||
|
|
||
|
|
||
|
export async function GET() {
|
||
|
|
||
|
|
||
|
const session = await getServerSession(authOptions);
|
||
|
|
||
|
if (session) {
|
||
|
|
||
|
return NextResponse.json(session)
|
||
|
}
|
||
|
return NextResponse.json({ error: "You must be logged in." }, { status: 401 });
|
||
|
}
|