I have a file stored in "@/lib/sessions.js
Its a file I use to handle my sessions.
In my session.js file, I have a map called "sessionMap" which stores key(sessionIds) and value(sessions).
In this file, I also have a function called DebugSessions() which tells me the size of the "sessionMap" variable.
While passing through the middleware, the size of "sessionMap" is always 0 but if its called elsewhere (for example: route handler) the current size of the "sessionMap" is logged.
I'm assuming that middlewares can't interact with sessionMap for some reason?
Whats the work around to this?
#Middleware can't access variables?
5 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
middlewares run in a completely different environment than the rest of the files, so they can't share the same memory. there is no workaround for this besides doing a network request to your server if you want to have persistent state across different middleware requests
Is that solution recommended? or would you recommend I go about what I'm trying to do via another method?
what exactly are you trying to do?