hostnames for dev

This commit is contained in:
Brandon Thomas committed 2026-04-05 19:12:01 -04:00
1 parent 08ebec8031
commit ddd019c521
5 files changed
+29 -14

No files matched your search

@@ -2,3 +2,6 @@
# Get the Client ID from the Google Cloud Console:
# https://console.cloud.google.com/apis/credentials
VITE_GOOGLE_CLIENT_ID=YOUR_CLIENT_ID.apps.googleusercontent.com
# API backend host. Defaults to https://api.storyteller.ai if unset.
# VITE_API_HOST=http://localhost:12345
+10 -9
View File
@@ -11,15 +11,16 @@ const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement,
);
// In development, route API through the Vite dev server origin to avoid CORS
if (import.meta.env.DEV) {
try {
const origin = window.location.origin;
StorytellerApiHostStore.getInstance().setApiSchemeAndHost(origin);
} catch (e) {
console.warn("Failed to set dev API host override", e);
}
}
// In development, route API through the Vite dev server proxy to avoid CORS,
// unless VITE_API_HOST is explicitly set (eg. for an unsafe browser that ignores CORS).
//if (import.meta.env.DEV && !import.meta.env.VITE_API_HOST) {
// try {
// const origin = window.location.origin;
// StorytellerApiHostStore.getInstance().setApiSchemeAndHost(origin);
// } catch (e) {
// console.warn("Failed to set dev API host override", e);
// }
//}
// Cache the referrer immediately — it can change or disappear on navigation.
// Only set once so subsequent in-site navigations don't overwrite the original.
+3 -1
View File
@@ -26,7 +26,9 @@ export class ApiManager {
}
protected getApiSchemeAndHost(): string {
return StorytellerApiHostStore.getInstance().getApiSchemeAndHost();
const host = StorytellerApiHostStore.getInstance().getApiSchemeAndHost();
console.log('getSchemaAndHost()', host);
return host;
}
public async fetch<B, T>(
+9 -3
View File
@@ -176,8 +176,10 @@ export class OmniGenApi extends ApiManager {
provider?: string,
): Promise<OmniGenImageModelsResponse> {
const query = provider ? { provider } : undefined;
const host = this.getApiSchemeAndHost();
console.log('getImageModels() - host', host);
return this.get<OmniGenImageModelsResponse>({
endpoint: `${this.getApiSchemeAndHost()}/v1/omni_gen/models/image`,
endpoint: `${host}/v1/omni_gen/models/image`,
query,
});
}
@@ -217,8 +219,10 @@ export class OmniGenApi extends ApiManager {
public async generateImage(
body: OmniGenImageRequest,
): Promise<OmniGenImageGenerateResponse> {
const host = this.getApiSchemeAndHost();
console.log('generateImage() - host', host);
return this.post<Record<string, unknown>, OmniGenImageGenerateResponse>({
endpoint: `${this.getApiSchemeAndHost()}/v1/omni_gen/generate/image`,
endpoint: `${host}/v1/omni_gen/generate/image`,
body: stripNulls(body),
});
}
@@ -226,8 +230,10 @@ export class OmniGenApi extends ApiManager {
public async generateVideo(
body: OmniGenVideoRequest,
): Promise<OmniGenVideoGenerateResponse> {
const host = this.getApiSchemeAndHost();
console.log('generateVideo() - host', host);
return this.post<Record<string, unknown>, OmniGenVideoGenerateResponse>({
endpoint: `${this.getApiSchemeAndHost()}/v1/omni_gen/generate/video`,
endpoint: `${host}/v1/omni_gen/generate/video`,
body: stripNulls(body),
});
}
@@ -1,5 +1,8 @@
// Artcraft / Storyteller API backend
const DEFAULT_API_HOST = "https://api.storyteller.ai";
// Set VITE_API_HOST=http://localhost:12345 for local dev, or leave unset for production.
//const DEFAULT_API_HOST = (import.meta as any).env?.VITE_API_HOST || "https://api.storyteller.ai";
const DEFAULT_API_HOST = "http://localhost:12345";
// NB(bt,2025-09-25): 'nx' is creating multiple copies of the library with name
// mangling, so the singleton pattern fails to resolve to a single instance.