Some tweaks

This commit is contained in:
cdricms
2026-03-21 11:53:25 +01:00
parent 4cf85981eb
commit 83eddf89cd
5 changed files with 22 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
import { API_URL } from "@/lib/constants";
import { ApiResponse } from "@/types/types";
import { getApiUrl } from "@/utils/api";
import { getCookie } from "cookies-next";
import { ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
export default async function request<T>(
@@ -20,7 +21,7 @@ export default async function request<T>(
if (options.csrfToken) {
const res: ApiResponse<{ csrf: string }> = await (
await fetch(`${API_URL}/csrf-token`, { credentials: "include" })
await fetch(`${getApiUrl()}/csrf-token`, { credentials: "include" })
).json();
if (res.data) headers["X-CSRF-Token"] = res.data.csrf;
}
@@ -39,7 +40,7 @@ export default async function request<T>(
headers.Authorization = `Bearer ${authToken}`;
}
const response = await fetch(`${API_URL}${endpoint}`, {
const response = await fetch(`${getApiUrl()}${endpoint}`, {
method,
headers,
body: body ? JSON.stringify(body) : undefined,