fix production attachment file origin

This commit is contained in:
richjohnrambo
2026-10-14 15:22:46 +08:00
parent c1338985d4
commit 8a26a4ccf9
4 changed files with 18 additions and 2 deletions
+6 -1
View File
@@ -12,6 +12,7 @@ import { useSessionStore } from '@/stores/session';
const DEFAULT_API_BASE = '/v1/im';
const DEFAULT_FILE_BASE = '/v0/file';
const CONFIGURED_FILE_BASE = import.meta.env.VITE_TINODE_FILE_BASE?.trim();
export class ImApiError extends Error {
reason?: string;
@@ -123,7 +124,11 @@ export function apiBase(): string {
export function fileBase(): string {
const endpoints = useSessionStore.getState().tenant?.endpoints;
return (endpoints?.file || DEFAULT_FILE_BASE).replace(/\/$/, '');
// Production may expose the web UI and the IM API through different deployments. Prefer the
// build-time canonical file origin so a tenant context previously resolved through the web host
// cannot keep routing attachments to that host's stale /v0/file proxy. Local development leaves
// this unset and continues to use the resolved relative endpoint through Vite's proxy.
return (CONFIGURED_FILE_BASE || endpoints?.file || DEFAULT_FILE_BASE).replace(/\/$/, '');
}
export function currentTenantCode(): string {