fix: route production IM API correctly
Deploy im-webapp production / deploy (push) Successful in 42s
Deploy im-webapp production / deploy (push) Successful in 42s
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_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 {
|
||||
|
||||
Vendored
+1
@@ -4,6 +4,7 @@
|
||||
declare const __APP_VERSION__: string;
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_TINODE_API_BASE?: string;
|
||||
readonly VITE_TINODE_API_KEY?: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user