fix: ensure supabase credentials are persistent on reloads
This commit is contained in:
@@ -70,10 +70,10 @@ export function SupabaseConnection() {
|
|||||||
}, [isConnected, supabaseConn.token]);
|
}, [isConnected, supabaseConn.token]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isConnected && supabaseConn.selectedProjectId && supabaseConn.token) {
|
if (isConnected && supabaseConn.selectedProjectId && supabaseConn.token && !supabaseConn.credentials) {
|
||||||
fetchProjectApiKeys(supabaseConn.selectedProjectId).catch(console.error);
|
fetchProjectApiKeys(supabaseConn.selectedProjectId).catch(console.error);
|
||||||
}
|
}
|
||||||
}, [isConnected, supabaseConn.selectedProjectId, supabaseConn.token]);
|
}, [isConnected, supabaseConn.selectedProjectId, supabaseConn.token, supabaseConn.credentials]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<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:
|
IMPORTANT: Create a .env file and ALWAYS populate the variables${
|
||||||
${
|
supabase?.credentials?.supabaseUrl && supabase?.credentials?.anonKey
|
||||||
supabase?.isConnected &&
|
? ` and include the following variables:
|
||||||
supabase?.hasSelectedProject &&
|
VITE_SUPABASE_URL=${supabase.credentials.supabaseUrl}
|
||||||
supabase?.credentials?.supabaseUrl &&
|
VITE_SUPABASE_ANON_KEY=${supabase.credentials.anonKey}`
|
||||||
supabase?.credentials?.anonKey
|
: '.'
|
||||||
? `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\`.
|
||||||
: 'SUPABASE_URL=your_supabase_url\nSUPABASE_ANON_KEY=your_supabase_anon_key'
|
|
||||||
}
|
|
||||||
NEVER modify any Supabase configuration or \`.env\` files.
|
|
||||||
|
|
||||||
CRITICAL DATA PRESERVATION AND SAFETY REQUIREMENTS:
|
CRITICAL DATA PRESERVATION AND SAFETY REQUIREMENTS:
|
||||||
- DATA INTEGRITY IS THE HIGHEST PRIORITY, users must NEVER lose their data
|
- 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 savedConnection = typeof localStorage !== 'undefined' ? localStorage.getItem('supabase_connection') : null;
|
||||||
|
const savedCredentials = typeof localStorage !== 'undefined' ? localStorage.getItem('supabaseCredentials') : null;
|
||||||
|
|
||||||
const initialState: SupabaseConnectionState = savedConnection
|
const initialState: SupabaseConnectionState = savedConnection
|
||||||
? JSON.parse(savedConnection)
|
? JSON.parse(savedConnection)
|
||||||
@@ -39,6 +40,14 @@ const initialState: SupabaseConnectionState = savedConnection
|
|||||||
project: undefined,
|
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);
|
export const supabaseConnection = atom<SupabaseConnectionState>(initialState);
|
||||||
|
|
||||||
if (initialState.token && !initialState.stats) {
|
if (initialState.token && !initialState.stats) {
|
||||||
|
|||||||
Reference in New Issue
Block a user