do stuffs

This commit is contained in:
2026-01-12 23:30:36 +01:00
parent 5729940a62
commit 4abe8a53df
8 changed files with 349 additions and 39 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.8.3
// protoc-gen-ts_proto v2.10.1
// protoc v6.33.1
// source: items.proto
+10
View File
@@ -1,16 +1,26 @@
import { AuthStatusRequest, AuthStatusResponse } from "../items";
export const getCsrfToken = (): string | null => {
const match = document.cookie.match(/csrf_token=([^;]+)/);
return match ? decodeURIComponent(match[1]) : null;
};
export const apiFetch = async (
url: string,
options: RequestInit = {}
): Promise<Response> => {
const token = localStorage.getItem("token");
const csrfToken = getCsrfToken();
const headers = new Headers(options.headers);
if (token) {
headers.set("Authorization", `Bearer ${token}`);
}
if (csrfToken) {
headers.set("X-CSRF-Token", csrfToken);
}
const config = {
...options,
headers,