fix: tailwind v4 postcss, auth-server session, eslint cleanups

This commit is contained in:
2025-10-09 15:47:56 +07:00
parent 670228b76e
commit bbfbc5b910
117 changed files with 4005 additions and 3414 deletions

31
frontend/lib/session.js Executable file
View File

@@ -0,0 +1,31 @@
// frontend/lib/session.js
import { cookies } from "next/headers";
const COOKIE_NAME = "access_token";
const API_BASE = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
/**
* Server-side function to get the current session from the request cookies.
* This can only be used in Server Components, Server Actions, or Route Handlers.
*/
export async function getSession() {
const cookieStore = cookies();
const token = cookieStore.get(COOKIE_NAME)?.value;
if (!token) return null;
try {
const res = await fetch(`${API_BASE}/api/auth/me`, {
headers: { Authorization: `Bearer ${token}` },
cache: "no-store",
});
if (!res.ok) return null;
const data = await res.json();
return data; // Expects { user, permissions, ... }
} catch (error) {
console.error("Error fetching session:", error);
return null;
}
}