lessquo
lessquo
Explore posts from servers
CDCloudflare Developers
Created by lessquo on 5/15/2024 in #pages-help
Error occurs accessing postgres with drizzle and postgres.js in Remix project
I've created a Remix project using create-cloudflare CLI as guided in https://developers.cloudflare.com/pages/framework-guides/deploy-a-remix-site/ and then I installed drizzle-orm and postgres, but I've got this error when I executed a simple select query:
Unexpected Server Error Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'cloudflare:
Unexpected Server Error Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'cloudflare:
The code:
export async function loader({ context }: LoaderFunctionArgs) {
const client = postgres(context.cloudflare.env.DATABASE_URL);
const db = drizzle(client);
const users = await db.select().from(userTable); // <- error here
return json({ users });
}
export async function loader({ context }: LoaderFunctionArgs) {
const client = postgres(context.cloudflare.env.DATABASE_URL);
const db = drizzle(client);
const users = await db.select().from(userTable); // <- error here
return json({ users });
}
This happens while running the app (remix vite:dev) locally.
3 replies