Added switch to render in JSON if API is the subdomain