I have some state that is unique for a user session, it is partially in the cookies, partially in the path params.
Before every route handler, I want to "do a bunch of stuff. And then put a resulting object in a shared cache that the route handler will use.
In NodeJS, I use middleware for that.
My understanding is that NextJS middleware is the wrong way to do it, but using react-cache and the layout is the right approach
So I used https://github.com/manvalls/server-only-context which wraps react-cache.
This works great for the pages, the layout populates the cache and the pages can access it.
But, I also use NextJS server actions. And it looks like the layout does not run before the server actions, so the cache is empty.
If I try to get the state from the cache in a server action, it is empty.
Any suggestions how to extend this pattern to NextJS server actions?