From 2c858929e4063ce56a0afa59d7da70488e9b57d1 Mon Sep 17 00:00:00 2001 From: makearmy Date: Mon, 29 Sep 2025 19:07:00 -0400 Subject: [PATCH] async cookies for rig builder --- app/rigs/RigBuilderServer.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/rigs/RigBuilderServer.tsx b/app/rigs/RigBuilderServer.tsx index acece3a6..7c9a3186 100644 --- a/app/rigs/RigBuilderServer.tsx +++ b/app/rigs/RigBuilderServer.tsx @@ -6,7 +6,7 @@ import RigBuilderClient from "./RigBuilderClient"; type Opt = { id: string | number; label: string }; export default async function RigBuilderServer() { - const jar = cookies(); + const jar = await cookies(); // <-- await in Next 15 const ma_at = jar.get("ma_at")?.value; if (!ma_at) { const next = encodeURIComponent("/rigs"); @@ -14,12 +14,10 @@ export default async function RigBuilderServer() { } const DIRECTUS = (process.env.DIRECTUS_URL || "").replace(/\/$/, ""); - // Fetch rig types on the SERVER with the user bearer const res = await fetch( `${DIRECTUS}/items/user_rig_type?fields=id,name&sort=sort`, { headers: { - // Build the bearer header explicitly from the raw cookie token Authorization: `Bearer ${ma_at}`, Accept: "application/json", "Cache-Control": "no-store", @@ -29,8 +27,6 @@ export default async function RigBuilderServer() { ); if (!res.ok) { - // If perms or token are wrong, fail loud so it’s obvious in dev - // (You can swap this for a quieter empty list if you prefer) const text = await res.text().catch(() => ""); throw new Error( `Failed to load user_rig_type (${res.status}): ${text || res.statusText}`