fix: route production IM API correctly
Deploy im-webapp production / deploy (push) Successful in 42s

This commit is contained in:
Your Name
2026-10-19 11:05:50 +08:00
parent d2b4cb0440
commit d7bfd2f417
5 changed files with 31 additions and 1 deletions
+5 -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_API_BASE = import.meta.env.VITE_TINODE_API_BASE?.trim();
const CONFIGURED_FILE_BASE = import.meta.env.VITE_TINODE_FILE_BASE?.trim();
export class ImApiError extends Error {
@@ -119,7 +120,10 @@ export function requestId(): string {
export function apiBase(): string {
const endpoints = useSessionStore.getState().tenant?.endpoints;
return (endpoints?.api || DEFAULT_API_BASE).replace(/\/$/, '');
// Production serves the static web app and IM API from different origins. The configured origin
// must also work before a tenant has been resolved, while local development keeps using Vite's
// same-origin proxy by leaving this value unset.
return (CONFIGURED_API_BASE || endpoints?.api || DEFAULT_API_BASE).replace(/\/$/, '');
}
export function fileBase(): string {