feat(supabase): add credentials handling for Supabase API keys and URL

This commit introduces the ability to fetch and store Supabase API keys and URL credentials when a project is selected. This enables the application to dynamically configure the Supabase connection environment variables, improving the integration with Supabase services. The changes include updates to the Supabase connection logic, new API endpoints, and modifications to the chat and prompt components to utilize the new credentials.
This commit is contained in:
KevIsDev
2025-03-20 11:17:27 +00:00
parent 02974089de
commit bc7e2c5821
11 changed files with 192 additions and 33 deletions

View File

@@ -0,0 +1,33 @@
import { json } from '@remix-run/node';
import type { ActionFunctionArgs } from '@remix-run/node';
export async function action({ request }: ActionFunctionArgs) {
try {
// Add proper type assertion for the request body
const body = (await request.json()) as { projectId?: string; token?: string };
const { projectId, token } = body;
if (!projectId || !token) {
return json({ error: 'Project ID and token are required' }, { status: 400 });
}
const response = await fetch(`https://api.supabase.com/v1/projects/${projectId}/api-keys`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
});
if (!response.ok) {
return json({ error: `Failed to fetch API keys: ${response.statusText}` }, { status: response.status });
}
const apiKeys = await response.json();
return json({ apiKeys });
} catch (error) {
console.error('Error fetching project API keys:', error);
return json({ error: error instanceof Error ? error.message : 'Unknown error occurred' }, { status: 500 });
}
}