#bypass workers with cookie

3 messages · Page 1 of 1 (latest)

knotty harness
#

Is there any way to bypass workers using a cookie?

For example in the case that something catastrophic is wrong with a worker I'd like to set a cookie and just send traffic directly to the origin.

untold ether
#

Nope

mild wagon
# knotty harness Is there any way to bypass workers using a cookie? For example in the case tha...

Not directly, you have a few other options though:

  1. You can have your worker handle looking at the cookie first thing it does and just return fetch(request). Less chance of it completely exploding early on
  2. You can call context.passThroughOnException(), which will pass through to the origin on an exception
    https://developers.cloudflare.com/workers/runtime-apis/handlers/fetch/
    Please note though that doesn't work in all cases. For example, it's a POST request and your worker already consumed the body, it's gone.