Remix integration issue
I integrated the postgres npm in my Remix project and used the sample code given on the Remix guide page. Everything is same as instructed on the guide but I get an error when I run the project:
[server] TypeError: Unsupported scheme "cloudflare" for module "cloudflare:sockets". Supported schemes: [
"data",
"blob",
"file",
"http",
"https",
]
8 Replies
metropolitan-bronze•2y ago
Hey @sachinbhatt, can you share the sample code? Where are you running the code? Local?
metropolitan-bronze•2y ago
It sounds like this might be a similiar issue: https://github.com/vercel/next.js/discussions/50177
GitHub
cloudflare plugin · vercel next.js · Discussion #50177
Summary Hi, I am a new developer trying to create a tool to visualize sql data tables, and to render and visualize the tables, I need a PostgreSQL URI so that i can connect to that database, but i ...
quickest-silverOP•2y ago
@ShinyPokemon Thanks for responding back. The link you shared addresses issue witih pg library while I am using postgres. I also tried downgrading postgres to 3.3.5 as it is inferred from the details on the official npm page of postgres that Cloudflares related feature requires 3.4.0 or higher. Anyway the code is as below:
=================================
--- app/db.server.ts
import postgres from "postgres";
const dbUrl:string = process.env.DATABASE_URL || "";
const sql = postgres(dbUrl, {ssl: 'require'});
// console.log("DB URl from environment:", dbUrl);
export {sql};
=================================
--- app/routes/readings._index.tsx
import { json } from "@remix-run/node";
import { sql } from "~/db.server";
import { useLoaderData } from "@remix-run/react";
export const loader = async () => {
const response = await sql
SELECT version();
return json({data: response});
}
export default function Readings () {
const sqlVersion = useLoaderData();
console.log("DB Version::", sqlVersion);
}
Oh and yes I am testing it locallymetropolitan-bronze•2y ago
Hey, I will test this out today. I'd like to see it reproduced in a minimal remix application
OK so I tested this out:
I then created the files you provided, executed
npm run dev and loaded http://localhost:3000/readings without any issues. The database version was printedmetropolitan-bronze•2y ago

metropolitan-bronze•2y ago
I think another module in your project is causing this issue
quickest-silverOP•2y ago
Thanks @ShinyPokemon for testing out. I also believe there is something related to one or more package clashes which are coming from the netlify template that I used to create the Remix project. I could still like to confirm by isolating them individually; for a reference would you please share your package json also?
metropolitan-bronze•2y ago
@sachinbhatt I deleted the project, but if you follow the commands I provided above you’ll end up in the same spot