15 lines
515 B
TypeScript
15 lines
515 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { djangoUrl } from "../proxy";
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const access = req.cookies.get("access_token")?.value;
|
|
const upstream = await fetch(djangoUrl("auth/me/"), {
|
|
method: "GET",
|
|
headers: access
|
|
? { Authorization: `Bearer ${access}` }
|
|
: { "Content-Type": "application/json" },
|
|
});
|
|
const data = await upstream.json().catch(() => ({}));
|
|
return NextResponse.json(data, { status: upstream.status });
|
|
}
|