fix
This commit is contained in:
@@ -16,18 +16,13 @@ export async function clientFetch(url: string, options: RequestInit = {}): Promi
|
||||
|
||||
// Ensure the url doesn't start with a slash if it's going to be appended to a URL that ends with one
|
||||
const cleanUrl = url.startsWith('/') ? url.substring(1) : url;
|
||||
|
||||
// IMPORTANT: Always use /api as the base URL for client-side requests
|
||||
// This ensures all requests go through Next.js API rewrite rules
|
||||
const baseUrl = '/api';
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL || '/api';
|
||||
|
||||
// Ensure there's only one slash between the base URL and endpoint
|
||||
const fullUrl = baseUrl.endsWith('/')
|
||||
? `${baseUrl}${cleanUrl}`
|
||||
: `${baseUrl}/${cleanUrl}`;
|
||||
|
||||
console.log(`[clientFetch] Requesting: ${fullUrl}`);
|
||||
|
||||
const res = await fetch(fullUrl, {
|
||||
...options,
|
||||
headers,
|
||||
|
||||
Reference in New Issue
Block a user