Rewrite with Ignored Build Step setting enabled

We have two Vercel projects in the same monorepo. Ones’ landing page will rewrite to the other one on all environments, even in preview URLs.

We’ve also enabled “Ignored Build Step” setting, which means that there are cases that the one won’t be build and so when the other tries to rewrite to it, it will fail with a 5xx error.

I’m wondering if there’s an option to maybe fallback to another URL when the build is skipped? Somehow maybe serve another branch or the previous commit?

Project information

Environment (local, preview, production): all
Project Framework: Next.js
Build Settings:
  Framework Preset:
  Build Command (if not default):
  Output Directory (if not default):
  Install Command (if not default):
Node/Runtime Version: 20.x
Package Manager: npm
Relevant Packages:

Hi, @kostas-pblworks! Welcome to the Vercel Community.

There’s no built-in Vercel feature to automatically fallback to another URL or serve another branch when a build is skipped due to the “Ignored Build Step” setting. But here are some suggestions:

  1. Conditional Rewrites: Instead of static rewrites, you could try using Vercel’s Edge Middleware. You could check if the target deployment is available before doing the rewrite so you’d fall back to the current project if the target isn’t available.

  2. Deployment Hooks: Have you considered setting up a deployment hook on the project that gets rewritten to? This could trigger a deployment on the other project whenever a successful build occurs, keeping both projects in sync.

  3. Shared Build Configuration: Maybe you could refactor your monorepo setup to have a shared build configuration? This could ensure both projects are built together, reducing the chances of one being built while the other is skipped.

  4. Caching Strategies: You could implement caching at the edge to serve stale content temporarily if the target project isn’t available. Vercel’s Edge Config or a third-party caching solution could help here.

  5. Health Checks: Implementing health checks in your apps could be useful. Before doing a rewrite, your app could check if the target is healthy and fall back to a default behavior if it’s not.

Hope this helps! Let me know if you have any other questions.

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