const cookieStore = await cookies(); doesnt re-run on middleware redirect, only first load
Unanswered
Keyhole wasp posted this in #help-forum
Keyhole waspOP
I have the middleware setup so taht when we send the client to /logout , the middleware deletes the cookies. In rootLayout, I have const cookieStore = await cookies(); which only runs on first page load, but not when navigating the pages. I need this to rerun so that the app knows there is no user anymore. I am setting and deleting cookies in middleware, which then get the user data in the middleware and send it to the rootlayout as a cookie, which then gets passed into a userContext provider. I need "const cookieStore = await cookies();" to run on redirects too not just first page load so that we can update the userContext to null. The cookies get cleared correctly, but userContext doesnt get updated since const cookieStore = await cookies(); doesnt rerun.