Skip to content

Unrestricted Open-source alternative to AI video platforms — Free AI image & video generation studio with 600+ models (Flux, Midjourney, Kling, Sora, Veo). No content filters. Self-hosted, MIT licensed.

fix(studio): route muapi.js calls through host proxy in the browser

Anil Matcha9ddd9033814d
diff --git a/packages/studio/src/muapi.js b/packages/studio/src/muapi.js
index 690e1eb7..5b3c651b 100644
--- a/packages/studio/src/muapi.js
+++ b/packages/studio/src/muapi.js
@@ -1,6 +1,11 @@
import { getModelById, getVideoModelById, getI2IModelById, getI2VModelById, getV2VModelById, getLipSyncModelById } from './models.js';
-const BASE_URL = 'https://api.muapi.ai';
+// In an http(s) browser we route through the host app's proxy (Next.js routes
+// under /api/* re-issue the call server-side) so api.muapi.ai CORS is bypassed.
+// SSR (no window) and Electron's file:// renderer call the upstream directly.
+const BASE_URL = (typeof window !== 'undefined' && window.location?.protocol?.startsWith('http'))
+ ? '/api'
+ : 'https://api.muapi.ai';
const PROXY_WF_BASE = '/api/workflow';
async function pollForResult(requestId, key, maxAttempts = 900, interval = 2000) {