- Added isomorphic-dompurify for improved XSS protection - Refactored token storage to use in-memory management for access tokens - Implemented server-side route handlers for OAuth token management - Introduced security headers in next.config.js - Removed client-side exposure of client_secret and sensitive tokens - Updated API interceptors to handle token refresh logic - Cleaned up cookie management for refresh tokens
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import TurnsPage from "@/components/panel/turns";
|
|
import { cookies } from "next/headers";
|
|
import { fetchReq } from "@/lib/req";
|
|
import { safeJsonParse } from "@/lib/sanitize";
|
|
import { adaptRepresentationDashboard } from "@/lib/representationAdapters";
|
|
import { getServerAccessToken } from "@/lib/serverToken";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
async function page() {
|
|
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
|
let dashboard = null;
|
|
|
|
try {
|
|
const cookieStore = await cookies();
|
|
const userInfo = cookieStore.get("userInfo");
|
|
|
|
if (userInfo) {
|
|
const parsedUserInfo = safeJsonParse(userInfo.value);
|
|
const representationUuid = parsedUserInfo?.representation_uuid;
|
|
|
|
if (representationUuid) {
|
|
const accessToken = await getServerAccessToken();
|
|
if (accessToken) {
|
|
const now = new Date();
|
|
const year = now.getFullYear();
|
|
const month = now.getMonth() + 1;
|
|
|
|
dashboard = await fetchReq(
|
|
`${API_URL}/api/v1/representation/${representationUuid}/dashboard/monthly?year=${year}&month=${month}`,
|
|
{ headers: { Authorization: `Bearer ${accessToken}` } }
|
|
);
|
|
}
|
|
}
|
|
}
|
|
} catch (error) {
|
|
console.error("Error fetching representation turns:", error);
|
|
}
|
|
|
|
return <TurnsPage data={adaptRepresentationDashboard(dashboard)} />;
|
|
}
|
|
|
|
export default page;
|