Set cookie for worker, access by worker not working.
I have been spinning my wheels for a couple of days on this. I don't believe that this is the same CORS request that a bunch folks have asked. All of my CORS values are set.
I am hosting my UI on a different domain. For now, it is a localhost domain. I am access my worker by way of API. I am returning a Set-Cookie value on the response of the API call. I can see that value in the developer tools of Chrome.
However when I got to make a get request on the same worker, the cookie is gone. I checked the application tab of developer tools for the cookie, no luck.
Basically the need is this. I want to assign a reward to you for calling the URL, and if I don't know who you are, I want you to register.
How do I crack this nut?
2 Replies
It was all CORS related, with Axios.
For anyone in the future looking into this.
You have to add:
Access-Control-Allow-Credentials: true
to your Cors response and set,
withCredentials on your request.
withCredentials will not work with cloudflare-workers