Supabase SSL - ENAMETOOLONG when adding sslrootcert to dbCredentials url
I'm trying to connect to my supabase with ssl-enabled using drizzle-kit but I keep on getting ENAMETOOLONG. I'm encoding the certificate into the connection url, but it seems like I'm reaching the limits of path length.
drizzle.config.ts:import { defineConfig } from 'drizzle-kit'import * as fs from 'fs'const caString = fs.readFileSync('./.supabase/certificates/prod-ca-2021.crt').toString()// URL encode the certificateconst caStringEncoded = encodeURIComponent(caString)// Construct the database URL with SSL parametersconst dbUrl = new URL(process.env.DEV_DATABASE_URL as string)dbUrl.searchParams.append('sslmode', 'require')dbUrl.searchParams.append('sslrootcert', caStringEncoded)export default defineConfig({ schema: './src/lib/database/schema.ts', out: './.drizzle/migrations', dialect: 'postgresql', dbCredentials: { url: dbUrl.toString() }})
drizzle.config.ts:import { defineConfig } from 'drizzle-kit'import * as fs from 'fs'const caString = fs.readFileSync('./.supabase/certificates/prod-ca-2021.crt').toString()// URL encode the certificateconst caStringEncoded = encodeURIComponent(caString)// Construct the database URL with SSL parametersconst dbUrl = new URL(process.env.DEV_DATABASE_URL as string)dbUrl.searchParams.append('sslmode', 'require')dbUrl.searchParams.append('sslrootcert', caStringEncoded)export default defineConfig({ schema: './src/lib/database/schema.ts', out: './.drizzle/migrations', dialect: 'postgresql', dbCredentials: { url: dbUrl.toString() }})
src/lib/database/db.ts:import { drizzle } from 'drizzle-orm/postgres-js'import postgres from 'postgres'import * as fs from 'fs'const client = postgres(process.env.DEV_DATABASE_URL as string, { ssl: { rejectUnauthorized: true, // Apply SSL certificate ca: fs.readFileSync('./.supabase/certificates/prod-ca-2021.crt').toString() }})export const db = drizzle(client)
src/lib/database/db.ts:import { drizzle } from 'drizzle-orm/postgres-js'import postgres from 'postgres'import * as fs from 'fs'const client = postgres(process.env.DEV_DATABASE_URL as string, { ssl: { rejectUnauthorized: true, // Apply SSL certificate ca: fs.readFileSync('./.supabase/certificates/prod-ca-2021.crt').toString() }})export const db = drizzle(client)
Ideally, I'd like to be able to have the certificate as an env (yeah, tired that, still the same length issue) so that a cloudflare worker which doesn't have acccess to the fs can connect.
I am using drizzle and drizzle-kit to run migrations against my supabase DB. I have SSL enforced, and can connect via psql (both with and without the SSL CLI flags, this doesn't make sense to m...