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): re-prompt for API key on 401/403 and harden header visibility

Anil Matcha958897e180dc
diff --git a/components/ApiKeyModal.js b/components/ApiKeyModal.js
index 94d62c1d..f415c31e 100644
--- a/components/ApiKeyModal.js
+++ b/components/ApiKeyModal.js
@@ -2,7 +2,7 @@
import { useState } from 'react';
-export default function ApiKeyModal({ onSave }) {
+export default function ApiKeyModal({ onSave, onClose, overlay = false, title, subtitle }) {
const [key, setKey] = useState('');
const [error, setError] = useState('');
@@ -13,9 +13,25 @@ export default function ApiKeyModal({ onSave }) {
onSave(trimmed);
};
+ const wrapperClass = overlay
+ ? 'fixed inset-0 z-[200] bg-black/70 backdrop-blur-sm flex items-center justify-center px-4 font-inter animate-fade-in-up'
+ : 'min-h-screen bg-[#030303] flex items-center justify-center px-4 font-inter';
+
return (
- <div className="min-h-screen bg-[#030303] flex items-center justify-center px-4 font-inter">
- <div className="w-full max-w-sm bg-[#0a0a0a]/40 backdrop-blur-xl border border-white/10 rounded-xl p-10 shadow-2xl">
+ <div className={wrapperClass}>
+ <div className="w-full max-w-sm bg-[#0a0a0a]/90 backdrop-blur-xl border border-white/10 rounded-xl p-10 shadow-2xl relative">
+ {overlay && onClose && (
+ <button
+ type="button"
+ onClick={onClose}
+ aria-label="Close"
+ className="absolute top-3 right-3 w-8 h-8 rounded-md text-white/40 hover:text-white hover:bg-white/10 transition-colors flex items-center justify-center"
+ >
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ )}
<div className="flex flex-col items-center text-center mb-10">
<div className="w-14 h-14 bg-[#22d3ee]/5 rounded-2xl flex items-center justify-center border border-[#22d3ee]/10 mb-6 group hover:border-[#22d3ee]/30 transition-colors">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#22d3ee" strokeWidth="1.5" className="group-hover:scale-110 transition-transform">
@@ -23,10 +39,12 @@ export default function ApiKeyModal({ onSave }) {
</svg>
</div>
<h1 className="text-xl font-bold text-white tracking-tight mb-2">
- Open Generative AI
+ {title || 'Open Generative AI'}
</h1>
<p className="text-white/40 text-[13px] leading-relaxed px-4">
- Enter your <a href="https://muapi.ai/access-keys" target="_blank" rel="noreferrer" className="text-[#22d3ee] hover:text-[#e5ff33] transition-colors">Muapi.ai</a> API key to start creating
+ {subtitle || (
+ <>Enter your <a href="https://muapi.ai/access-keys" target="_blank" rel="noreferrer" className="text-[#22d3ee] hover:text-[#e5ff33] transition-colors">Muapi.ai</a> API key to start creating</>
+ )}
</p>
</div>
diff --git a/components/StandaloneShell.js b/components/StandaloneShell.js
index 5ddb6012..bb811a44 100644
--- a/components/StandaloneShell.js
+++ b/components/StandaloneShell.js
@@ -61,7 +61,7 @@ export default function StandaloneShell() {
const [apiKey, setApiKey] = useState(null);
const [activeTab, setActiveTab] = useState(getInitialTab());
-
+
const [balance, setBalance] = useState(null);
const [showSettings, setShowSettings] = useState(false);
const [isHeaderVisible, setIsHeaderVisible] = useState(true);
diff --git a/packages/studio/src/muapi.js b/packages/studio/src/muapi.js
index 46ba18f4..67c0644d 100644
--- a/packages/studio/src/muapi.js
+++ b/packages/studio/src/muapi.js
@@ -8,6 +8,12 @@ const BASE_URL = (typeof window !== 'undefined' && window.location?.protocol?.st
: 'https://api.muapi.ai';
const PROXY_WF_BASE = '/api/workflow';
+function notifyAuthRequired(status, detail) {
+ if (typeof window === 'undefined') return;
+ if (status !== 401 && status !== 403) return;
+ window.dispatchEvent(new CustomEvent('muapi:auth-required', { detail: { status, message: detail } }));
+}
+
async function pollForResult(requestId, key, maxAttempts = 900, interval = 2000) {
const pollUrl = `${BASE_URL}/api/v1/predictions/${requestId}/result`;
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
@@ -19,6 +25,7 @@ async function pollForResult(requestId, key, maxAttempts = 900, interval = 2000)
if (!response.ok) {
const errText = await response.text();
if (response.status >= 500) continue;
+ notifyAuthRequired(response.status, errText);
throw new Error(`Poll Failed: ${response.status} - ${errText.slice(0, 100)}`);
}
const data = await response.json();
@@ -41,6 +48,7 @@ async function submitAndPoll(endpoint, payload, key, onRequestId, maxAttempts =
});
if (!response.ok) {
const errText = await response.text();
+ notifyAuthRequired(response.status, errText);
throw new Error(`API Request Failed: ${response.status} ${response.statusText} - ${errText.slice(0, 100)}`);
}
const submitData = await response.json();
@@ -209,6 +217,7 @@ export function uploadFile(apiKey, file, onProgress) {
} catch (e) {
// fallback to statusText
}
+ notifyAuthRequired(xhr.status, detail);
reject(new Error(`File upload failed: ${xhr.status} - ${detail}`));
}
};
@@ -227,6 +236,7 @@ export async function getUserBalance(apiKey) {
});
if (!response.ok) {
const errText = await response.text();
+ notifyAuthRequired(response.status, errText);
throw new Error(`Failed to fetch balance: ${response.status} - ${errText.slice(0, 100)}`);
}
return await response.json();