NeonN
Neon8mo ago
6 replies
efficient-indigo

neon with cloudflare hyperdrive in hono.js using postgres.js

hello everyone,

i'm having this error that I haven't quite know how to solve yet. it's related to using neon with postgres.js and hyperdrive

i'm trying to set up a connection as follows:

import { Context } from 'hono';
import postgres from 'postgres';

const db = (c: Context) => {
  console.log('Connecting to database...');
  console.log(c.env.HYPERDRIVE.connectionString);

  const connectionString = c.env.HYPERDRIVE?.connectionString;

  return postgres(connectionString, {
    fetch_types: false
  });
};

export default db;

but this is the output that I'm getting in the console:

Connecting to database...
postgresql://neondb_owner:*************@91a7****************d1e4c29.hyperdrive.local:5432/neondb?sslmode=disable
✘ [ERROR] PostgresError: connection is insecure (try using `sslmode=require`)


i'm not sure what I'm supposed to do since the url provided by hyperdrive has sslmode=false.

can anyone point me in the right direction?
Was this page helpful?