From 87261c6b92250562cf36290b43cbd0d284c9e3c3 Mon Sep 17 00:00:00 2001 From: Damjan Savic Date: Sun, 25 Jan 2026 06:33:36 +0100 Subject: [PATCH] auto-claude: subtask-1-2 - Create client-side CSRF token retrieval utility --- src/lib/csrf/client.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/lib/csrf/client.ts diff --git a/src/lib/csrf/client.ts b/src/lib/csrf/client.ts new file mode 100644 index 0000000..49c0c03 --- /dev/null +++ b/src/lib/csrf/client.ts @@ -0,0 +1,17 @@ +const CSRF_META_TAG_NAME = 'csrf-token'; + +/** + * Get the CSRF token from the meta tag in the document head + * The server should render: + */ +export function getCsrfToken(): string | null { + if (typeof document === 'undefined') { + return null; + } + + const metaTag = document.querySelector( + `meta[name="${CSRF_META_TAG_NAME}"]` + ); + + return metaTag?.content || null; +}