Is it possible to use the D1 rest API but lockdown the API key to only that D1 database
Is it possible to use the D1 rest API but lockdown the API key to only that D1 database
wrangler.toml:wrangler d1 migrations apply prod-main --local (or even without --local) it says: wrangler d1 migrations apply prod-main -e production --localpreview and a production environment variable has made it not work locally inside the svelte kit app this is my app.d.tsproduction variable in both Platform and where I use it: env.production.db but no diceTypeError: Cannot read properties of undefined (reading 'prepare')Unlike Workers Environments, production and preview are the only two options available via [env.<ENVIRONMENT>] on Pages
/api/create/[user] routeconst result = await db.select().from(schema.users); also doesn't query, same errorenv: {},... so it's not loading anythingsvelte.config.js file i had to set platformProxy.environment to 'production' inside the adapter's config




name = "[the name]"
compatibility_date = "2024-07-29"
pages_build_output_dir = ".svelte-kit/cloudflare"
[[env.production.d1_databases]]
binding = "db"
database_name = "prod-main"
database_id = "524d4c4f-410b-46f9-9a87-2dc4f6110b1c"
[[env.preview.d1_databases]]
binding = "db"
database_name = "dev-main"
database_id = "025df237-d405-4f57-859f-ad3a055fd74b" ⛅️ wrangler 3.72.0
-------------------
✘ [ERROR] Couldn't find a D1 DB with the name or binding 'prod-main' in wrangler.toml.interface Platform {
env: {
db: D1Database;
};
}const db = await drizzle(platform?.env.db, { schema });interface Platform {
env: {
db: D1Database;
};
}export const GET: RequestHandler = async ({ params, platform }) => {
if (platform === undefined) return new Response('err');
if (params.user === undefined) return new Response('err');
const db = await drizzle(platform?.env.db, { schema });
const result = await db.insert(schema.users).values({ name: params.user });
return new Response(JSON.stringify(result));
};