ugh
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
import { cookies } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { getServerApiUrl } from './api-utils';
|
||||
|
||||
/**
|
||||
* Constructs a server-side API URL for backend requests
|
||||
* Used in Server Components and API routes to directly access the backend API
|
||||
*
|
||||
* @param endpoint The API endpoint path
|
||||
* @returns A complete URL to the backend API
|
||||
*/
|
||||
function getServerApiUrl(endpoint: string): string {
|
||||
const apiUrl = process.env.SERVER_API_URL || 'https://internal-api.inboxi.ng/api';
|
||||
const cleanEndpoint = endpoint.startsWith('/') ? endpoint.substring(1) : endpoint;
|
||||
|
||||
return apiUrl.endsWith('/')
|
||||
? `${apiUrl}${cleanEndpoint}`
|
||||
: `${apiUrl}/${cleanEndpoint}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Server-side fetch wrapper with authentication.
|
||||
|
||||
Reference in New Issue
Block a user