Using a worker to proxy a request to a different subdomain

I have a worker which is proxying requests to different urls by reconstructing requests and then returning fetch(). This makes it look like the user stays on a single domain but pages may be resolved from elsewhere.

This works fine until I try to proxy to a subdomain of the domain which my worker is running on, at which point the URL changes to the target.

i.e

example.com/hello -> proxied to a different domain and returned to user, they stay on the same url

example.com/bye -> proxied a subdomain of example -> they change url to the subdomain

Could someone explain why this happens please?