aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/src/utils.ts
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-16 19:37:50 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-16 19:40:10 -0800
commitcba29e6aae637b04ff6eaf28f74bc15b6242b9ea (patch)
tree226753a3fcd18a6d45089dafcb1ee72557140aa8 /frontend/src/utils.ts
parentcb6d0c9e330c27ff85ff065c2ea6dd1a756cbf6d (diff)
downloadneko-cba29e6aae637b04ff6eaf28f74bc15b6242b9ea.tar.gz
neko-cba29e6aae637b04ff6eaf28f74bc15b6242b9ea.tar.bz2
neko-cba29e6aae637b04ff6eaf28f74bc15b6242b9ea.zip
Remove legacy V2 React frontend and update build/test scripts to focus on Vanilla JS (V3)
Diffstat (limited to 'frontend/src/utils.ts')
-rw-r--r--frontend/src/utils.ts32
1 files changed, 0 insertions, 32 deletions
diff --git a/frontend/src/utils.ts b/frontend/src/utils.ts
deleted file mode 100644
index ebfb692..0000000
--- a/frontend/src/utils.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-export function getCookie(name: string): string | undefined {
- const value = `; ${document.cookie}`;
- const parts = value.split(`; ${name}=`);
- if (parts.length === 2) return parts.pop()?.split(';').shift();
-}
-
-/**
- * A wrapper around fetch that automatically includes the CSRF token
- * for state-changing requests (POST, PUT, DELETE).
- */
-export async function apiFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
- const method = init?.method?.toUpperCase() || 'GET';
- const isStateChanging = ['POST', 'PUT', 'DELETE'].includes(method);
-
- const headers = new Headers(init?.headers || {});
-
- if (isStateChanging) {
- const token = getCookie('csrf_token');
- if (token) {
- headers.set('X-CSRF-Token', token);
- }
- }
-
- // Ensure requests are treated as coming from our own origin if needed,
- // but for a same-origin API, standard fetch defaults are usually fine.
-
- return fetch(input, {
- ...init,
- headers,
- credentials: 'include', // Ensure cookies are sent
- });
-}