working ! testing !
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 2m41s

This commit is contained in:
2025-11-25 00:33:03 -08:00
parent 5b00e64e3c
commit 217894342d

View File

@@ -80,12 +80,9 @@ const refreshToken = async (): Promise<string> => {
* @returns A promise that resolves to the fetch Response.
*/
export const apiFetch = async (url: string, options: RequestInit = {}, tokenOverride?: string): Promise<Response> => {
// In the Node.js test environment, we must use the full URL.
// In the browser, relative URLs are fine.
// We use the joinUrl helper to prevent `new URL()` from stripping base paths like '/api'.
const fullUrl = (typeof window === 'undefined' && !url.startsWith('http'))
? joinUrl(API_BASE_URL, url)
: url;
// Always construct the full URL from the base and the provided path,
// unless the path is already a full URL. This works for both browser and Node.js.
const fullUrl = url.startsWith('http') ? url : joinUrl(API_BASE_URL, url);
logger.debug(`apiFetch: ${options.method || 'GET'} ${fullUrl}`);
@@ -153,10 +150,8 @@ export const apiFetch = async (url: string, options: RequestInit = {}, tokenOver
* @returns A promise that resolves to the fetch Response.
*/
export const apiFetchWithAuth = async (url: string, options: RequestInit, tokenOverride?: string): Promise<Response> => {
// In the Node.js test environment, we must use the full URL.
const fullUrl = (typeof window === 'undefined' && !url.startsWith('http'))
? joinUrl(API_BASE_URL, url)
: url;
// Always construct the full URL from the base and the provided path.
const fullUrl = url.startsWith('http') ? url : joinUrl(API_BASE_URL, url);
logger.debug(`apiFetchWithAuth: ${options.method || 'GET'} ${fullUrl}`);