bolt.diy/app/routes/api.supabase.variables.ts
KevIsDev 4b0eaf25ce add: add env masking extension for .env files
Introduce a new extension for CodeMirror that masks sensitive values in .env files. This ensures that sensitive information like API keys or passwords is not displayed in plain text within the editor. The extension dynamically applies masking to values in lines matching the KEY=VALUE format, improving security during development.
2025-03-27 18:52:13 +00:00

33 lines
1.1 KiB
TypeScript

import { json, type ActionFunctionArgs } from '@remix-run/cloudflare';
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 });
}
}