Skip to content

Commit

Permalink
Fix D1_ERROR: not authorized
Browse files Browse the repository at this point in the history
- we're trying to read an internal table column - given we have no authority to do so during runtime, the query to get columns will fail and result the error.
  • Loading branch information
zeviance authored Jan 26, 2024
1 parent a809f5a commit 22ef08e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/routes/api/db/[database]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const GET: RequestHandler = async ({ params, locals, url, fetch, platform
throw error(404, "No tables found");
}
const results = tables.results.filter(({ name }) => {
// Avoid all Cloudflare internal table names.
if (name.startsWith("_cf_")) {
return false;
}
if (name.startsWith("sqlite_") || name.startsWith("d1_")) {
return !!platform?.env.SHOW_INTERNAL_TABLES;
}
Expand Down

0 comments on commit 22ef08e

Please sign in to comment.