How to use ${_self.CA_CERT} in when accessing Postgres DB from Nodejs app?

Goal is to avoid Error: self signed certificate in certificate chain or disabling it by setting Node env.

I do not think copying content from ${_self.CA_CERT} env to file and uploading it to repository and referring it as file approach sounds safe. There is support page describing saving it using script and referring it at runtime, I tried it like


even tried setting NODE_EXTRA_CA_CERTS

I am using Postgraphile as middleware in my case, trying to connect to dev database.

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I was able to fix this in Postgraphile by using Pool from pg

export const pool = new Pool({
    user: process.env.DB_USERNAME,
    host: process.env.DB_HOSTNAME,
    database: process.env.DATABASE,
    password: process.env.DB_PASSWORD,
    port: Number(process.env.DB_PORT),
    ssl: {
       rejectUnauthorized: true,
       ca: process.env.CA_CERT,

and passing pool object postgraphile

const middleware = postgraphile(db, schemas, options)