diff --git a/content/200-orm/200-prisma-client/500-deployment/101-traditional/200-deploy-to-heroku.mdx b/content/200-orm/200-prisma-client/500-deployment/101-traditional/200-deploy-to-heroku.mdx index 246d8cc293..d45ffd8200 100644 --- a/content/200-orm/200-prisma-client/500-deployment/101-traditional/200-deploy-to-heroku.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/101-traditional/200-deploy-to-heroku.mdx @@ -269,6 +269,18 @@ const server = app.listen(PORT, () => { - **Database URL**: As part of Heroku's provisioning process, a `DATABASE_URL` config var is added to your app’s configuration. This contains the URL your app uses to access the database. Ensure that your `schema.prisma` file uses `env("DATABASE_URL")` so that Prisma Client can successfully connect to the database. +* **Disable SSL certificate validation**: When using the `PrismaPg` adapter with `DATABASE_URL`, make sure to disable SSL certificate validation in line with [Heroku's guidelines](https://devcenter.heroku.com/articles/connecting-heroku-postgres#connecting-in-node-js). Failing to do so can result in a `P1010 DriverAdapterError: DatabaseAccessDenied` error. You can handle this conditionally based on whether the database is local or hosted on Heroku: + +```js +const isSecureDb = !process.env.DATABASE_URL.includes("@127.0.0.1") + +export const db = new PrismaClient({ + adapter: new PrismaPg({ + connectionString: process.env.DATABASE_URL + (isSecureDb ? `?sslmode=no-verify` : "") + }) +}) +``` + ## Summary Congratulations! You have successfully deployed a Node.js app with Prisma ORM to Heroku.