Reverse Proxy Worker forwarding requests to Zero Trust backend causing a 302 redirection loop.
My reverse proxy worker seems to be dropping the CF-Auth tokens from Zero trust when forwarding with the only code being return fetch(event.request). Any ideas to help solve this issue?
6 Replies
What does your code look like?
addEventListener(“fetch” (event) => {
event.respondWith(fetch(event.request))
})
Should snote, that I suspect it’s the auth cookies getting lost with the fetch call because I can see them come in on event.request, but with Zero Trust active it’s causing a 302 redirection loop tying to authenticate
Access runs in front of workers so your code will never reach the worker if it isn't authenticated
It’s authenticated when the request hits the worker. We suspect that the fetch is dropping the cookies to the backend since it sends 302s as a response
The loop we’re seeing is, even with a valid cloudflare access token in the browser:
User -> worker -> example.com -302-> cloudflare access.com -302 -> worker -> example.com
Ah unfortunately never used access with workers so hopefully someone else knows more
Darn. Yeah. The reverse proxy bit works just fine without access and the access works just fine without there worker. So there’s some conflict going on
Seeing if anyone else has worked with a reverse proxy worker behind zero trust before