Error when setting NODE_ENV=production on Digital Ocean

Self hosting on Digital Ocean App Platform
Managed Database
Followed instructions here: DigitalOcean App Platform | Strapi Documentation

It almost seems like the Managed Database is not connected to the application for some reason.

Any ideas on what I can do to resolve this error?

This topic has been created from a Discord post (1265349758508339241) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

printenv DATABASE_URL

Update:

Current path of solving:

I don’t believe I need to set the DATABASE_URL or DATABASE_CA myself per this issue: Getting strapi working on digitalocean app plattform - #5 by mrt-stl

If I delete the DATABASE_URL and DATABASE_CA (*That I manually created), and if I go to the console I can run printenv DATABASE_URL and printenv DATABASE_CA. Those values are returned in the console.

SOLVED!

The error:

"Could not load js config file /workspace/config/env/production/database.js: Cannot read properties of undefined (reading 'charAt')"

This clearly tells us there was a problem reading or finding the process.env.DATABASE_URL variable in the config/env/production/database.js file, and has it coming back as undefined.

Although, we know that we can still access the variable using printenv DATABASE_URL using DO’s console.

Step 1: I manually added back the DATABASE_URL and DATABASE_CA per the youtube instructions. So it looks like the image I posted in the original images with this issue.

Step 2: (see images attached to this) There were actually multiple DATABASE_URL’s with different scopes! You can see that the manual one I entered has a scope of RUN_AND_BUILD_TIME while the one that was created automatically by Digital Ocean when I connected my managed database just has RUN_TIME.

Solve 1: I deleted the one that was created automatically by Digital Ocean.

Solve 2: Delete manual ones, but change the scope to RUN_AND_BUILD_TIME

Resources for solution:

  1. In the official documentation there was a WARNING! that helped lead me here:
  1. In the Forum there was a comment that led me to this solution:
    “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.”