We are having issues with Azure Front Doors CDN on one of our routes. The route is pointing towards a App service that's running a node with a Next.JS v13 application. The caching of SSR pages works fine most of the time but periodically the CDN misses before the "s-maxage" is up and the page 400s with no content on the page request. The "s-maxage" is set to 86400, but the cache misses start well before then.
Looking into the access logs for Front door, we can see that the request is being sent to the correct endpoint, the routing rule name is the same as the endpoint. And an error info of: "OriginError". Following the same request to the web app HTTP logs we can see that it has been requested fine and is passing back a 200 code. No issues from Next.JS. What is weird is that when the page is refreshed the CDN misses again but the page loads fine, but then if the page is refreshed again it errors. It does this continually in a loop; until the CDN hits again and returns fine from then on until the issue starts again. Another thing to note is the "routingRuleName" in the Front door access logs are different for when the cache miss happens it goes from the specific route name to the name of the endpoint. But the request still manages to end up going to the web app.
OriginError is marked as "Generic origin error" which isn't helpful to go off as what we can see from the App service is a 200 error and a success message.
Can someone help us figure out what is going wrong?