fix: bootstrap admin CSRF tokens

This commit is contained in:
simoleo89
2026-08-02 11:46:43 +02:00
parent a57c73055f
commit b3245a18ea
8 changed files with 270 additions and 45 deletions
+10
View File
@@ -139,6 +139,16 @@ function trySetCsrfCookie(
}
}
/** Read-only access for Server Components, which cannot write response cookies. */
export async function readCsrfCookieToken(): Promise<string> {
try {
return readExistingCsrfCookie(await cookies()) ?? "";
} catch {
logger.warn("Failed to read CSRF cookie");
return "";
}
}
/** Sets the CSRF cookie when possible; returns token or empty string (never throws). */
export async function setCsrfCookie(): Promise<string> {
try {