Skip to content

Commit 97f7ed4

Browse files
Add note about Heroku SSL connection (#7039)
Co-authored-by: Patrick Jakubik <37963339+patryk-smc@users.noreply.github.com> Co-authored-by: Aidan McAlister <105178005+aidankmcalister@users.noreply.github.com>
1 parent 240696f commit 97f7ed4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

content/200-orm/200-prisma-client/500-deployment/101-traditional/200-deploy-to-heroku.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ const server = app.listen(PORT, () => {
269269

270270
- **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.
271271

272+
* **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:
273+
274+
```js
275+
const isSecureDb = !process.env.DATABASE_URL.includes("@127.0.0.1")
276+
277+
export const db = new PrismaClient({
278+
adapter: new PrismaPg({
279+
connectionString: process.env.DATABASE_URL + (isSecureDb ? `?sslmode=no-verify` : "")
280+
})
281+
})
282+
```
283+
272284
## Summary
273285

274286
Congratulations! You have successfully deployed a Node.js app with Prisma ORM to Heroku.

0 commit comments

Comments
 (0)