Pages confuse preview domain and ship production deployment

For Workers & Pages, what is the name of the domain?

rvt.app

What is the issue or error you’re encountering

Starting a couple weeks ago, my end-to-end tests started to fail sometimes. Looking at the log, it’s clear that sometimes (mostly firefox) receives the production deployment https://rvt.app when requesting the preview deployment https://preview.rvt.app

What are the steps to reproduce the issue?

This is very strange behavior, which started a couple weeks ago.

Source: GitHub - phi-ag/rvt-app: Display Revit file information in the browser

Reproducing this is hard, as it happens only sometimes. The best way I found is re-opening the preview branch link https://main.rvt-app.pages.dev/ in Firefox and after a couple of tries it will open https://rvt.app instead of https://preview.rvt.app

The redirect code is extremely simple and can be found here: rvt-app/src/middleware.ts at main · phi-ag/rvt-app · GitHub

I’m unable to reproduce the problem using curl:

curl -o /dev/null -s -w "%{redirect_url}\n" https://main.rvt-app.pages.dev/

This always returns the correct redirect. Wtf is happening in Firefox :confused:

Edit: same issue reported here Caching issue with Custom Domain for preview branches