Using a REST API with Cloudflare as sub-domain issues

502 means your server reported a Bad Gateway error - it isn’t generated by Cloudflare.

Check your server’s error logs for the reason.