lets hope this doesn't break stuff

This commit is contained in:
NotII
2025-03-08 05:49:04 +00:00
parent 47e23caf66
commit 9fe457dee7
2 changed files with 9 additions and 6 deletions

View File

@@ -18,7 +18,10 @@ export async function fetchClient<T>(
const { method = 'GET', body, headers = {}, ...rest } = options;
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001';
const url = `${apiUrl}/api${endpoint.startsWith('/') ? endpoint : `/${endpoint}`}`;
// Check if endpoint already includes /api
const apiPrefix = endpoint.includes('/api/') ? '' : '/api';
const url = `${apiUrl}${apiPrefix}${endpoint.startsWith('/') ? endpoint : `/${endpoint}`}`;
const fetchOptions: RequestInit = {
method,