Store auth0 jwt token in the cookie

Hi. I’m working on a JAMStack website and we use auth0 for our authentication process.
The problem is that I have some important logic on edge functions, that requires the authorization of the user. So I have to store the jwt token in the cookies and synchronize it with the latest state of the auth0-spa-js library. But it’s a little tricky and there are some bugs, for example, sometimes the token gets removed(or at least not sent to server) even while the user is authenticated.
Is there any better workaround/best practice for this problem? Or I should try to bugfix my own implementation?

If you explain your requirement then it would be easy tp propose a solution for this.

@rashid779939
I have a Cloudflare worker, which restrict access to some pages based on the token user provides.
So I need the token to be present in the first request (when user types the URL and presses enter)
The only way I can be sure that the token is in the first request is to use cookies which are sent by the browser by default.