fix(deploy): prevent duplicated api prefix
This commit is contained in:
+1
-1
@@ -21,7 +21,7 @@ COPY packages/ ./packages/
|
|||||||
COPY apps/admin-web/ ./apps/admin-web/
|
COPY apps/admin-web/ ./apps/admin-web/
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
ARG VITE_API_BASE_URL=/api
|
ARG VITE_API_BASE_URL=
|
||||||
RUN pnpm --filter admin-web build
|
RUN pnpm --filter admin-web build
|
||||||
|
|
||||||
# ─── Stage 2: Serve with nginx ─────────────────────────────────────────────────
|
# ─── Stage 2: Serve with nginx ─────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -130,13 +130,22 @@ import {
|
|||||||
markImageUploadRequestStarted,
|
markImageUploadRequestStarted,
|
||||||
} from "./image-webp";
|
} 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 generationStreamEnabled = import.meta.env.VITE_GENERATION_STREAM_ENABLED === "true";
|
||||||
const accessRefreshSkewMs = 2 * 60 * 1000;
|
const accessRefreshSkewMs = 2 * 60 * 1000;
|
||||||
|
|
||||||
const publicClient = createApiClient({ baseURL });
|
const publicClient = createApiClient({ baseURL });
|
||||||
let storedRefreshPromise: Promise<AuthTokens> | null = null;
|
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 {
|
export function getApiBaseURL(): string {
|
||||||
if (baseURL) {
|
if (baseURL) {
|
||||||
return baseURL;
|
return baseURL;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ monitoring_database:
|
|||||||
max_idle_conns: 2
|
max_idle_conns: 2
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
addr: localhost:6379
|
addr: redis:6379
|
||||||
db: 0
|
db: 0
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
|
|||||||
Reference in New Issue
Block a user