can i use a outside variable to join messages two-by-two #1158
Replies: 2 comments 1 reply
-
When running your API Routes via Serverless, different requests will be handled by different Lambda instances. They don't share their variables, so this won't work as you think it will - each job is executed on a different handler, so they all start fresh with an empty I'd recommend you keep your API stateless, and store this data in an external database - for example Postgres or Redis. |
Beta Was this translation helpful? Give feedback.
-
I'll use the same redis instance that is used by Quirrel to store it, any problem?. Just one more question, i can't use the enqueue method at the front-end side because the next can only access env variables by typing NEXT_PUBLIC at the variable's name beginning then i put the enqueue method in an api route. I am using Next13 btw. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
i have no experience working with queues specially in NextJs so a question that is in my mind it's a good approach have a variable to join messsages in my case i wanna have it two by two, like in the code below
as you can see the messages variable is outside and will store all income messages, is it a good approach or there is a better way?
Beta Was this translation helpful? Give feedback.
All reactions