Azure AD Application Proxy Vs Cloudflare

Since we changed the exposure mode of some of our web services, we get 504 Gateway timeout errors that we didn’t have before.
We used to use a simple ARR iis reverse proxy that exposed the service, now we have switched to Azure AD Application proxy and we get these issues.

Could you please help us resolve this issue?

Thanks you