Hey!
I discovered Cloudflare workers, looking for a way to redirect my users depending on their country, if they don’t have a pre-existing cookie. I previously did this directly from my PHP script.
This means that a french user going to mywebsite.com, would:
- Load the page.
- Get redirected to
fr.mywebsite.com. - Load again
fr.mywebsite.com.
I thought workers would prevent the first load, and redirect instantly to fr.mywebsite.com without going to my server.
What I’m having a hard time understanding from this example is why do we have to fetch the page anyway? Is fetch actually loading the page, or just looking if it returns a 200 status code?
On a side note, I think there’s an error on Random Content Cookies example: it should probably return modifiedResponse.