Using render.com instead of Netlify and Heroku

Here are some instructions for self hosting on Render.com:

RedwoodJS is architected as monorepo with two separate sides, an “api side” and a “web side.” The api side is a NodeJS application and the web side is a static SPA (single page app). This works out great when hosting on render.com because hosting a static site is free, and static content is served via super-fast CDN.

So we’re going to setup two sides on Render.com, but first you need to add some things to your RedwoodJS project.

Setup the “api” side.

  1. Install the api-server in your api side.
cd api
yarn add @redwoodjs/api-server
  1. Create a “health” function:

The health function is used by Render to check if your api side is running correctly.

// ./api/src/functions/healthz.js
export const handler = async () => {
    return {
        statusCode: 200
    }
}

On render.com, create a new "web service"

  1. Connect to your repository
  2. Environment is Node
  3. Build is yarn && yarn rw prisma migrate deploy && yarn rw build api
  4. Start is cd api && yarn rw-api-server --port 80
  5. Use a custom domain: “api.raccoon.trade”

On render.com, create a new "static site"

  1. Build is yarn && yarn rw build web
  2. Publish is ./web/dist
  3. Add rewrite and redirect rules:

6 Likes