Trying to get Strapi v4 to work on Render.com

System Information
  • Strapi Version: 4.0
  • Operating System: Debian GNU/Linux 10 (buster)
  • Database: SQLite
  • Node Version: 14.18.2
  • NPM Version: 6.14.15
  • Yarn Version: 1.22.5

I am trying to get Strapi v4.0 to work on Render .com. I was using this guide and trying to port this repo to work on v4.0 but I don’t know how to move the code in /config/env/production/server.js and /config/env/production/middleware.js to the new structure of v4.0 and get it to work. I tried to follow the v4.0 documentation of the middleware but I’m not able to get it to work properly.

The problem I’m facing
I think the data isn’t stored in the right place. I tried to edit /config/middleware.js and change the path of strapi::public with:

  {
    name: 'strapi::public',
    config: {
      path: '/data/public'
    },
  },

But when a new commit starts a new deploy all the data is lost that I set previously. So I’m assuming that the right path isn’t used.

Can anybody help me to point me in the right direction for the changes I need to make to get it to work properly on Render .com? Thanks!

Hello. I’m having the same problems too…
I guess with the new update the documentation is out of date.

The only thing that I have been able to investigate is that for the data to be saved in render, you first have to create a database (PostgreSQL) and then connect the strapi app.
If you only use one disk, the information will be erased every time you deployment.

Here’s a better explanation than mine;):

Thanks for your answer.

I’ve gotten a step closer. I’ve got Render working with SQLite by editing config/database.js and changing the filename property from:

filename: path.join(__dirname, '..', env('DATABASE_FILENAME', '.tmp/data.db')),

to:

filename: env('DATABASE_FILENAME', path.join(__dirname, '..', '.tmp/data.db')),

The problem was that path.join was adding __dirname in front of DATABASE_FILENAME so it was being directed to a non existing path because DATABASE_FILENAME is already an absolute path ('/data/public').

So the database is fixed. But the next problem is that I’m unable to overwrite the default path of the public directory. I’m trying to upload the images to the /data/public directory on the root of my server because that’s where the persistent disk is located. But I’m unable to set it. Check this issue for more information about that.

Cheers,
h00x

We’ve released an updated, official Render template for Strapi. Our examples:

1 Like

I tried a lot of the above, including the official Strapi render templates.

The clean template deploys properly, but somehow as soon as I update the template to v4.2.2 and add some models the render deploy breaks. Really can’t put my finger on it.

Switching to Railway.app literally solved all my problems in minutes. No code changes.

Also, it’s promising to be cheaper than Render. So that’s a bonus. And Render had a history of random outages in the Frankfurt region that weren’t logged properly in the status dashboard. Incident reports were missing or said services were down for a few minutes, when it was hours instead. So maybe the Render problems are a sign to abandon and move. I’m kinda sad to be leaving Render, I loved being able to choose which region my data lives in.

1 Like

Little edit, I kept running into performance problems, even on Railway.app (and after upgrading the plan) more details in the comment here: