first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 22:14:08 +03:00
commit b2825e1698
41 changed files with 14258 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { NextResponse } from "next/server";
import { cookies } from "next/headers";
import { COOKIE_ACCESS } from "@/lib/auth-cookies";
const BASE_URL =
process.env.BASE_API_URL ?? process.env.NEXT_PUBLIC_BASE_API_URL ?? "http://127.0.0.1:8080";
export async function GET() {
const cookieStore = await cookies();
const accessToken = cookieStore.get(COOKIE_ACCESS)?.value;
if (!accessToken) {
return NextResponse.json({ loggedIn: false });
}
try {
const res = await fetch(`${BASE_URL}/api/v1/auth/me`, {
headers: {
accept: "application/json",
Authorization: `Bearer ${accessToken}`,
},
});
if (!res.ok) {
return NextResponse.json({ loggedIn: false });
}
const data = await res.json();
return NextResponse.json({
loggedIn: true,
user: (data as { user?: unknown }).user,
});
} catch {
return NextResponse.json({ loggedIn: false });
}
}