You’d need to use a reverse proxy. Either do it your self, which is tough, or I remember there was a tool for it here on the forum, i don’t remember the name tho
Pros: free-ish (depending on your needs, it might cost), easy to set up
Cons: if you want to do something more complex in the future, you may have to go with another solution later.
Cloudflare Workers
Pros: free, provides more flexibility
Cons: set up is more complex and requires some programming experience and Cloudflare specific setup
nginx
Pros: most flexible for anything you want and is incredibly fast
Cons: this one requires the most knowledge to set up and requires additional infrastructure to set up and run nginx
For the specific case you mentioned, I’d probably recommend giving CoAlias and Cloudflare Workers a try (both of them) for free and see which of them get what you want.