Thanks. This is what I get for using these big static site generators that I don't entirely understand, turns out this was a result of setting the base URL in Hugo to $CF_PAGES_URL as recommended by the CloudFlare docs.
Thank you for investigating this - I got scared when I saw what looked like an ephemeral URL!