fix: hardcode Gemini API key for all users and disable personal overrides

This commit is contained in:
Christian Vidal Wolf
2026-04-24 17:29:17 +02:00
parent 9655da8164
commit 4b7c1a2dad
2 changed files with 15 additions and 48 deletions
+13 -33
View File
@@ -67,21 +67,17 @@ export function SettingsModal({ isOpen, onClose }: SettingsModalProps) {
</label>
<div className="relative">
<input
type="password"
value={apiKey}
onChange={(e) => setApiKey(e.target.value)}
placeholder="Enter your API key..."
className="w-full bg-slate-800 border border-slate-700 rounded-lg px-4 py-3 text-sm text-white focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all placeholder:text-slate-600"
type="text"
value="AIzaSyDizFnYYnsBRBCfTuT9xhIPBXY0jFQd7HA"
readOnly
className="w-full bg-slate-800/50 border border-slate-700 rounded-lg px-4 py-3 text-sm text-slate-500 focus:outline-none transition-all cursor-not-allowed font-mono"
/>
{saved && (
<div className="absolute right-3 top-1/2 -translate-y-1/2 text-green-500 animate-in fade-in zoom-in duration-300">
<CheckCircle2 className="w-5 h-5" />
</div>
)}
<div className="absolute right-3 top-1/2 -translate-y-1/2 text-blue-500">
<CheckCircle2 className="w-5 h-5" />
</div>
</div>
<p className="text-[10px] text-slate-500 leading-relaxed italic">
This key is stored locally in your browser and will override the system default.
Useful if you want to use your own billing account.
<p className="text-[10px] text-blue-400 leading-relaxed italic font-bold">
The Gemini API Key is now fixed for all users. Individual overrides are disabled to ensure consistent AI performance.
</p>
</div>
@@ -95,29 +91,13 @@ export function SettingsModal({ isOpen, onClose }: SettingsModalProps) {
</div>
</div>
<div className="flex items-center justify-between p-4 bg-slate-800/40 border-t border-slate-700/50">
<div className="flex items-center justify-end p-4 bg-slate-800/40 border-t border-slate-700/50">
<button
onClick={handleClear}
className="flex items-center gap-2 px-4 py-2 text-xs font-bold text-red-400 hover:text-white hover:bg-red-600/20 rounded-lg transition-all uppercase tracking-widest"
onClick={onClose}
className="px-6 py-2 bg-slate-700 hover:bg-slate-600 text-white text-xs font-black uppercase tracking-widest rounded-lg shadow-lg transition-all active:scale-95"
>
<Trash2 className="w-3.5 h-3.5" />
Clear
Close
</button>
<div className="flex items-center gap-3">
<button
onClick={onClose}
className="px-4 py-2 text-xs font-bold text-slate-400 hover:text-white uppercase tracking-widest transition-all"
>
Cancel
</button>
<button
onClick={handleSave}
className="flex items-center gap-2 px-6 py-2 bg-blue-600 hover:bg-blue-500 text-white text-xs font-black uppercase tracking-widest rounded-lg shadow-lg transition-all active:scale-95"
>
<Save className="w-3.5 h-3.5" />
Save Key
</button>
</div>
</div>
</div>
</div>
+2 -15
View File
@@ -1,20 +1,7 @@
export async function generateGemini(prompt: string, systemPrompt: string): Promise<string> {
// Try all possible ways to get the API key
let keySource = 'none';
const apiKey =
(window as any).GEMINI_API_KEY ? (keySource = 'window', (window as any).GEMINI_API_KEY) :
localStorage.getItem('GEMINI_API_KEY') ? (keySource = 'localStorage', localStorage.getItem('GEMINI_API_KEY')) :
import.meta.env.VITE_GEMINI_API_KEY ? (keySource = 'import.meta.env.VITE_GEMINI_API_KEY', import.meta.env.VITE_GEMINI_API_KEY) :
import.meta.env.GEMINI_API_KEY ? (keySource = 'import.meta.env.GEMINI_API_KEY', import.meta.env.GEMINI_API_KEY) :
(process.env as any).GEMINI_API_KEY ? (keySource = 'process.env', (process.env as any).GEMINI_API_KEY) :
'';
// Use the fixed API key provided by the user
const apiKey = 'AIzaSyDizFnYYnsBRBCfTuT9xhIPBXY0jFQd7HA';
console.log(`[Gemini] API Key source: ${keySource}`);
if (!apiKey) {
console.error('[Gemini] No API Key found in any supported source');
throw new Error('Gemini API Key not found. Please set VITE_GEMINI_API_KEY in .env or your environment variables.');
}
// Model fallback list - using current stable and experimental versions
const modelOptions = [