fixing proxy

This commit is contained in:
2026-02-20 18:58:04 -06:00
parent d3e59e63f7
commit 68f05fb517
2 changed files with 31 additions and 11 deletions
+21 -6
View File
@@ -4,10 +4,25 @@ import BarNavigation from "../BarNavigation/BarNavigation";
import header from "./Header.module.css";
import BarNavigationServicio from "../BarNavigation/BarNavigationServicio";
import { cookies } from "next/headers";
import { jwtVerify } from "jose";
import { redirect } from "next/navigation";
const secret = new TextEncoder().encode(process.env.JWT_SECRET);
export default async function Header() {
const cookieStore = await cookies();
const role = cookieStore.get("role")?.value || "";
const cookieStore = cookies();
const token = (await cookieStore).get("token")?.value;
let role: number = 5;
if (token) {
try {
const { payload } = await jwtVerify(token, secret);
role = payload.role as number;
} catch (error) {
role = 5;
}
}
return (
<header className={header.header}>
@@ -29,11 +44,11 @@ export default async function Header() {
</Link>
<div className={header.yellowPart}></div>
<div className={header.containerBarNav}>
{role === "1" && <BarNavigation />}
{role === "4" && <BarNavigation />}
{role === 1 && <BarNavigation />}
{role === 4 && <BarNavigation />}
{role === "2" && <BarNavigationServicio/>}
{role === "3" && <BarNavigationServicio/>}
{role === 2 && <BarNavigationServicio/>}
{role === 3 && <BarNavigationServicio/>}
</div>
</header>
);