I had a hard time as well figuring out how to connect the APP and Database on Digitalocean. Here’s what worked for me:
As @tw1t611 mentioned, the DATABASE_URL: ${<<yourDbName>>.DATABASE_URL} env variable doesn’t seem to work as we expect it at the moment. So setting the variable to the connection string is fixing this. BUT: I figured out that DO sets the DATABASE_URL env automatically when you connect a database to the app. In my case: These env variable is not shown in the Environment Variables section in the settings but in the config .yaml file (under a second envs key). In my case there where 3 DATABASE_URL variables because I changed connected DBs. I had to delete all of them to make my manually set DATABASE_URL (the connection string) env working again. Alternatively you can just name your variable differently.
In my code:
I had to install pg and pg-connection-string packages and add these code to my config/production/database.js:
Just want to thank you. I’ve been for 6 or 8 straight hours without any hope of fixing the issue. Strapi couldnt pass the proper values on the production env, and after i made these suggested changes it finaly built