mirror of
https://github.com/stackblitz-labs/bolt.diy.git
synced 2025-06-18 01:49:07 +01:00
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.
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
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 });
|
|
}
|
|
}
|