fix production attachment file origin
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user