JSON Response from Cloudflare 501 error

Hi, is there a way to have Cloudflare respond with Json if a request is using Application/Json?

Can you elaborate and give an example?

So I need Cloudflare to produce an application/json response when my websites API goes down.

Something like:
{“success”:false, “cause” : “webhost down”}

Just so my applications know that the site is down, I could use the HTML but it means i’d have to modify some software I dont own to have it work which is why i kinda need CF to be able to do this :slight_smile:

You can do that with Cloudflare workers.

Code sample

1 Like