Add configurable internal API URL

This commit is contained in:
Mike Cao committed 2026-05-09 01:06:52 -07:00
1 parent fa182d0947
commit 2fd319f910
6 files changed
+124 -4

No files matched your search

+2 -3
View File
@@ -1,6 +1,7 @@
import { useMutation, useQuery } from '@tanstack/react-query';
import { usePathname } from 'next/navigation';
import { useCallback } from 'react';
import { getApiUrl } from '@/lib/api-url';
import { getClientAuthToken } from '@/lib/client';
import { SHARE_CONTEXT_HEADER, SHARE_TOKEN_HEADER } from '@/lib/constants';
import { type FetchResponse, httpDelete, httpGet, httpPost, httpPut } from '@/lib/fetch';
@@ -31,10 +32,8 @@ export function useApi() {
authorization: `Bearer ${getClientAuthToken()}`,
...shareHeaders,
};
const basePath = process.env.basePath;
const getUrl = (url: string) => {
return url.startsWith('http') ? url : `${basePath || ''}/api${url}`;
return getApiUrl(url);
};
const getHeaders = (headers: any = {}) => {