Monorepo PR previews with changes in more than service

I have a monorepo with 2 services, backend and frontend, whenever I make changes to both the BE and FE I’d like to have my FE preview to connect to the BE preview, however im unsure on what configs im missing and how to send the BE created preview url to the FE service.

Additionally when I only make changes to 1 of them and not both, I’d like to either:

  • have both services PR previews created
  • make sure the FE connects to the dev BE service

Hi Roberto,

Thanks for reaching out.

It sounds like you may want Preview Environments based on a Blueprint rather than Pull Request Previews. That way, both services would be spun up to ensure the Preview Environment was two separate services that are set to call each other. You may be able to use Build Filters to further restrict subsequent commits to be dependent on what code has been touched.

This render.yaml example shows the basic setup to have a Preview Environment of a monorepo, with the frontend getting an env var set based on the backends public URL.

previewsEnabled: trueservices: - type: web name: monorepo-frontend env: static buildCommand: npm run build staticPublishPath: ./public rootDir: frontend envVars: - key: BACKEND_PUBLIC_URL fromService: name: monorepo-backend type: web envVarKey: RENDER_EXTERNAL_HOSTNAME - type: web name: monorepo-backend env: node buildCommand: npm install startCommand: node app.js rootDir: backend

Hope that helps

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.