Custom response for API

Hi, we’re hosting bunch of things off the one domain.

  • marketing site
  • web app
  • API

We’ve started switching on Cloudflare piece by piece across the entire domain. One issue we’ve run across is that it isn’t clear how we can return a custom response on a 500 error from the server. It looks like we can return a page, but not a API response.

In an ideal world, we’d be able to control this by page rules. So that we return a response for api.mydomain, then a different one for www.mydomain and another one for app.mydomain.

Sorry for the delay. I don’t think that’s something that can be accomplished with a page rule. It may be something you can do with a Cloudflare Worker, or with a change at your origin.