fix(deploy): prevent duplicated api prefix
This commit is contained in:
@@ -130,13 +130,22 @@ import {
|
||||
markImageUploadRequestStarted,
|
||||
} from "./image-webp";
|
||||
|
||||
const baseURL = import.meta.env.VITE_API_BASE_URL ?? "";
|
||||
const rawBaseURL = import.meta.env.VITE_API_BASE_URL ?? "";
|
||||
const baseURL = normalizeApiBaseURL(rawBaseURL);
|
||||
const generationStreamEnabled = import.meta.env.VITE_GENERATION_STREAM_ENABLED === "true";
|
||||
const accessRefreshSkewMs = 2 * 60 * 1000;
|
||||
|
||||
const publicClient = createApiClient({ baseURL });
|
||||
let storedRefreshPromise: Promise<AuthTokens> | null = null;
|
||||
|
||||
function normalizeApiBaseURL(value: string): string {
|
||||
const trimmed = value.trim().replace(/\/+$/, "");
|
||||
if (!trimmed) {
|
||||
return "";
|
||||
}
|
||||
return trimmed.replace(/\/api$/i, "");
|
||||
}
|
||||
|
||||
export function getApiBaseURL(): string {
|
||||
if (baseURL) {
|
||||
return baseURL;
|
||||
|
||||
Reference in New Issue
Block a user