All queries are dependent on a cookie value, need some advice on best approach
I have a lot of queries, and all of them depend on a cookie to be present for headers. Its getting a bit annoying to use the enabled / skipToken approach on all of the queries. Is there something I can do with the defaultOptions? Or should I just render the app when the cookie is present
3 Replies
like-gold•16mo ago
What is the cookie? This sounds like something that would fall under authentication so Protected routes is probably the best option
flat-fuchsiaOP•16mo ago
organization ID
the whole application falls under these cookies
like-gold•16mo ago
It sounds like you're trying to implement a solution in the wrong spot. Either protected routes or if you're using a fetching lib like axios/ky, throwing an error from there could work.
We forcefully redirect to
/login if any request returns a 401 in our ky afterResponse hook
We also use react-router for a protected route too. The ky hook is just a failsafe if they've been afk for too long or were logged out via other means