a month ago
I am connecting to a supabase database and wondering how to get my login working ASAP.
15 Replies
a month ago
I have attached the server logs... (screenshots).
Attachments
a month ago
If you want this to work ASAP for now, while you find a solution for ssl, you can disable ssl in your db ORM config, either via the connection string: connectionString: ${process.env.DATABASE_URL}?sslmode=no-verify , or via the config object; example in drizzle ORM config:
connection: {
connectionString: process.env.DATABASE_URL,
ssl: false
}a month ago
You can check this github issue as well, as it details how to setup ssl in your drizzle config (if you're using drizzle).
darseen
You can check this github issue as well, as it details how to setup ssl in your drizzle config (if you're using drizzle).
a month ago
I will check this out now to see what happens.
darseen
If you want this to work ASAP for now, while you find a solution for ssl, you can disable ssl in your db ORM config, either via the connection string: connectionString: ${process.env.DATABASE_URL}?sslmode=no-verify , or via the config object; example in drizzle ORM config:connection: { connectionString: process.env.DATABASE_URL, ssl: false }
a month ago
I have been prompted by Claude to at the no-reply to the variable URL/string in Railway. I will confirm that it is back in the string and check the code in the drizzle config file... Claude would point me to db.ts file I will see if I have a drizzle config file.
a month ago
I gave it a shot by updating the drizzle.config file and the connection string in Railway Service Variables and I see get this error message...
Login attempt for username: aligons@uemergeacademy.com
Login error details: {
message: 'Database error: self-signed certificate in certificate chain',
stack: 'Error: Database error: self-signed certificate in certificate chain\n' +
' at /app/dist/index.cjs:338:3546\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:105:5)',
username: 'aligons@uemergeacademy.com'
}
Database error during getUserByUsername: Error: self-signed certificate in certificate chain
at /app/dist/index.cjs:52:13330
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async /app/dist/index.cjs:70:31368
at async Mh.getUserByUsername (/app/dist/index.cjs:70:101062)
at async /app/dist/index.cjs:338:3434 {
code: 'SELF_SIGNED_CERT_IN_CHAIN'
}
Login error: Error: Database error: self-signed certificate in certificate chain
at /app/dist/index.cjs:338:3546
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
a month ago
Can you share your drizzle config file? And make sure you are making changes in the file where you initialize your db client not in your drizzle.config.ts
a month ago
Sure... I asked Claude to update the file and it suggested updating the db.ts file to be the same code... here's the code
import "dotenv/config";
import { defineConfig } from "drizzle-kit";
if (!process.env.SUPABASE_DATABASE_URL) {
throw new Error("SUPABASE_DATABASE_URL is not set");
}
export default defineConfig({
out: "./migrations",
schema: "./shared/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: process.env.SUPABASE_DATABASE_URL + "?sslmode=no-verify",
},
});
Also, a ran the console commands git... to push to Railway and redeployed the updates... I am assuming the last line of code is the correct update... however, I notice no change by Claude in the code mirrowing your specific code update.
a month ago
The code you provided is for drizzle-kit and is located in drizzle.config.ts . This file is not related to your db client (which is probably located in db.ts).That's why your db queries are still failing because you haven't changed the db client's config. You need to make the suggested changes in yourdb.ts . If you could paste the contents of it here, so I can look at it. It would be great.
a month ago
Claude suggested that I change the db.ts to the same as the drizzle.config.ts. I have the back up files... sounds like I need to show you the original db.ts file, put my drizzle.config back and make changes to the db.ts file... Here are the original files:
original drizzle.config
import "dotenv/config";
import { defineConfig } from "drizzle-kit";
if (!process.env.SUPABASE_DATABASE_URL) {
throw new Error("SUPABASE_DATABASE_URL is not set");
}
export default defineConfig({
out: "./migrations",
schema: "./shared/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: process.env.SUPABASE_DATABASE_URL,
},
});
original db.ts
import "dotenv/config";
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
if (!process.env.SUPABASE_DATABASE_URL) {
throw new Error("SUPABASE_DATABASE_URL is not set");
}
export const pool = new Pool({
connectionString: process.env.SUPABASE_DATABASE_URL,
ssl: { rejectUnauthorized: false },
});
export const db = drizzle(pool);
both files are back to these files...
a month ago
Following supabase's docs for setting up drizzle. Try using postgres instead of node-posrgres
Run npm i postgresdb.ts file:
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
let connectionString = process.env.DATABASE_URL;
export const client = postgres(connectionString, { prepare: false });
export const db = drizzle(client);
Alternatively disable ssl in your db.ts file:
import "dotenv/config";
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
if (!process.env.SUPABASE_DATABASE_URL) {
throw new Error("SUPABASE_DATABASE_URL is not set");
}
export const pool = new Pool({
connectionString: `${process.env.SUPABASE_DATABASE_URL}?sslmode=no-verify`,
ssl: false,
});
export const db = drizzle(pool);a month ago
I really recommend that you host your database on Railway instead of connecting to an external db (supabase in this case), so you don't incur additional egress charges and have lower latency. This way you pay less money and have faster response times.
a month ago
I was sure if I am to combine the two pieces of code... I like the idea of another platform... would it be easier to export the database, import it into the new platform and connect it to my web app at this point... I have been set back a week with this issue and not sure I will in front of my deadline of a program I am running.
a month ago
Yeah, it sounds like a reasonable idea. Backup your data and restore it in the new database. You can disable ssl for now, so you app keeps working at least while you do the migration.
a month ago
Ok... I see the no verify piece in the code for SSL, but do I still need the to go to node-postgres or stay with postgres on the new platform... I will jump on this tomorrow to get Claude to walk me through the steps. Thank you for your help.