feat: Store API key locally in browser instead of build-time
- Add apiKeyService for localStorage-based API key management - Add ApiKeyModal component for entering/updating API key - Update geminiService to use dynamic API key - Remove .env.example as API key is now user-provided - Update to gemini-2.0-flash model The API key is now stored only in the user's browser localStorage, making the app more secure and easier to deploy. https://claude.ai/code/session_01DBAyjuKW8Qtzixc64qn9KP
This commit is contained in:
parent
1a758f9f8c
commit
b23daec6e5
5 changed files with 155 additions and 11 deletions
18
services/apiKeyService.ts
Normal file
18
services/apiKeyService.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const STORAGE_KEY = 'gemini_api_key';
|
||||
|
||||
export const getApiKey = (): string | null => {
|
||||
return localStorage.getItem(STORAGE_KEY);
|
||||
};
|
||||
|
||||
export const setApiKey = (key: string): void => {
|
||||
localStorage.setItem(STORAGE_KEY, key);
|
||||
};
|
||||
|
||||
export const clearApiKey = (): void => {
|
||||
localStorage.removeItem(STORAGE_KEY);
|
||||
};
|
||||
|
||||
export const hasApiKey = (): boolean => {
|
||||
const key = getApiKey();
|
||||
return key !== null && key.length > 0;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue