File size: 457 Bytes
1fe7075
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
/**
 * node-postgres reads `sslmode=require` as "verify the certificate"; libpq (and the
 * BAETES API) only require encryption. Keep the libpq meaning so both APIs share DATABASE_URL.
 */
export function pgConnectionString(url: string): string {
  const parsed = new URL(url);
  if (parsed.searchParams.has('sslmode') && !parsed.searchParams.has('uselibpqcompat')) {
    parsed.searchParams.set('uselibpqcompat', 'true');
  }
  return parsed.toString();
}