mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
fix: ensure supabase credentials are persistent on reloads
This commit is contained in:
parent
6a79bc6e5b
commit
a109fc127f
@ -70,10 +70,10 @@ export function SupabaseConnection() {
|
||||
}, [isConnected, supabaseConn.token]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isConnected && supabaseConn.selectedProjectId && supabaseConn.token) {
|
||||
if (isConnected && supabaseConn.selectedProjectId && supabaseConn.token && !supabaseConn.credentials) {
|
||||
fetchProjectApiKeys(supabaseConn.selectedProjectId).catch(console.error);
|
||||
}
|
||||
}, [isConnected, supabaseConn.selectedProjectId, supabaseConn.token]);
|
||||
}, [isConnected, supabaseConn.selectedProjectId, supabaseConn.token, supabaseConn.credentials]);
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
|
@ -80,17 +80,14 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
|
||||
: ''
|
||||
: ''
|
||||
}
|
||||
IMPORTANT: Create a .env file if it doesnt exist and include the following variables:
|
||||
${
|
||||
supabase?.isConnected &&
|
||||
supabase?.hasSelectedProject &&
|
||||
supabase?.credentials?.supabaseUrl &&
|
||||
supabase?.credentials?.anonKey
|
||||
? `VITE_SUPABASE_URL=${supabase.credentials.supabaseUrl}
|
||||
VITE_SUPABASE_ANON_KEY=${supabase.credentials.anonKey}`
|
||||
: 'SUPABASE_URL=your_supabase_url\nSUPABASE_ANON_KEY=your_supabase_anon_key'
|
||||
}
|
||||
NEVER modify any Supabase configuration or \`.env\` files.
|
||||
IMPORTANT: Create a .env file and ALWAYS populate the variables${
|
||||
supabase?.credentials?.supabaseUrl && supabase?.credentials?.anonKey
|
||||
? ` and include the following variables:
|
||||
VITE_SUPABASE_URL=${supabase.credentials.supabaseUrl}
|
||||
VITE_SUPABASE_ANON_KEY=${supabase.credentials.anonKey}`
|
||||
: '.'
|
||||
}
|
||||
NEVER modify any Supabase configuration or \`.env\` files apart from creating the \`.env\`.
|
||||
|
||||
CRITICAL DATA PRESERVATION AND SAFETY REQUIREMENTS:
|
||||
- DATA INTEGRITY IS THE HIGHEST PRIORITY, users must NEVER lose their data
|
||||
|
@ -27,6 +27,7 @@ export interface SupabaseConnectionState {
|
||||
}
|
||||
|
||||
const savedConnection = typeof localStorage !== 'undefined' ? localStorage.getItem('supabase_connection') : null;
|
||||
const savedCredentials = typeof localStorage !== 'undefined' ? localStorage.getItem('supabaseCredentials') : null;
|
||||
|
||||
const initialState: SupabaseConnectionState = savedConnection
|
||||
? JSON.parse(savedConnection)
|
||||
@ -39,6 +40,14 @@ const initialState: SupabaseConnectionState = savedConnection
|
||||
project: undefined,
|
||||
};
|
||||
|
||||
if (savedCredentials && !initialState.credentials) {
|
||||
try {
|
||||
initialState.credentials = JSON.parse(savedCredentials);
|
||||
} catch (e) {
|
||||
console.error('Failed to parse saved credentials:', e);
|
||||
}
|
||||
}
|
||||
|
||||
export const supabaseConnection = atom<SupabaseConnectionState>(initialState);
|
||||
|
||||
if (initialState.token && !initialState.stats) {
|
||||
|
Loading…
Reference in New Issue
Block a user