mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:35:24 +02:00
fix: exhaustive API key lookup and injection for Vercel
This commit is contained in:
@@ -29,11 +29,18 @@ Guidelines:
|
||||
|
||||
// Helper to get API key safely
|
||||
const getApiKey = (): string | undefined => {
|
||||
try {
|
||||
return process.env.API_KEY;
|
||||
} catch (e) {
|
||||
// Try different sources (Vite defines these at build time)
|
||||
const key =
|
||||
(typeof process !== 'undefined' && process.env ? process.env.API_KEY || process.env.GEMINI_API_KEY : undefined) ||
|
||||
(import.meta as any).env?.VITE_GEMINI_API_KEY ||
|
||||
(import.meta as any).env?.API_KEY ||
|
||||
(import.meta as any).env?.GEMINI_API_KEY;
|
||||
|
||||
// Ensure it's not a literal "undefined" string from a failed build injection
|
||||
if (key === "undefined" || key === "null" || !key) {
|
||||
return undefined;
|
||||
}
|
||||
return key;
|
||||
};
|
||||
|
||||
const formatCurrency = (val: number) => `€${val.toLocaleString('de-DE', { minimumFractionDigits: 0, maximumFractionDigits: 0 })}`;
|
||||
|
||||
Reference in New Issue
Block a user