Custom response for API


#1

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.


#2

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.