mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-11 17:29:48 +02:00
Fixes "The server does not support SSL connections" by disabling SSL in DATABASE_URL for local Docker deployments and in server/db.ts. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 4b008663-bd72-492b-b0b6-fa252367e730 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/4b008663-bd72-492b-b0b6-fa252367e730/QW0MKzv
27 lines
954 B
TypeScript
27 lines
954 B
TypeScript
import { Pool } from 'pg';
|
|
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
import * as schema from "@shared/schema";
|
|
|
|
if (!process.env.DATABASE_URL) {
|
|
throw new Error(
|
|
"DATABASE_URL must be set. Did you forget to provision a database?",
|
|
);
|
|
}
|
|
|
|
// Configuration de connexion avec SSL désactivé pour Docker local
|
|
const connectionConfig = {
|
|
connectionString: process.env.DATABASE_URL,
|
|
ssl: false // Désactiver SSL pour production Docker locale
|
|
};
|
|
|
|
// Si DATABASE_URL contient déjà sslmode=disable, ne pas forcer SSL
|
|
if (process.env.DATABASE_URL?.includes('sslmode=disable')) {
|
|
connectionConfig.ssl = false;
|
|
} else if (process.env.NODE_ENV === 'production' && !process.env.DATABASE_URL?.includes('localhost')) {
|
|
// Activer SSL uniquement pour production externe (pas Docker local)
|
|
connectionConfig.ssl = { rejectUnauthorized: false };
|
|
}
|
|
|
|
export const pool = new Pool(connectionConfig);
|
|
|
|
export const db = drizzle(pool, { schema }); |