Invalid Login when Access Protected Site Proxied through worker

I have a pages site that is OTP protected via Access. For accessing the preview deployments via wildcard subdomain, I set up a worker that rewrites the hostname in the headers.

When I try to access the site via the worker, it gives an invalid login session error. The error is the same even when a new session is started in an incognito window.

How do I fix this?