Include db certs in a serverless function

I am using digital ocean managed mongo db service for my site. They require that you provide a ca certificate in order to establish connection to the managed db. I am able to get the connection to work locally, but not in production

/cert
  certificate.cert
/functions

Current implementation

async function connectToDatabase() {
  if (cachedDb) return cachedDb;

  const client = await MongoClient.connect(process.env.MONGO_CONNECTION_URI, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    ...(process.env.APP_Env !== "dev"
      ? {
            tlsCAfile: path.join(__dirname, "../cert/ca-certificate.crt"),
        }
      : {}),
  });

.........

This does not work when in production. What is the best to include this cert when trying to connect to a db?

Hey @aoloo,

Does this help: