Token in Next.js 14 server actions
Unanswered
Common Sandpiper posted this in #help-forum
Common SandpiperOP
Hi, I'm trying to use
My problem is that from the action I can't access anything related to the client (quite slow of me to realise this just now hahahaha), either
Now this leaves me with the question of whether requests should be made in the action or am I missing the point, as any kind of request with
useFormState together with Next.js 14 server actions, inside my action I validate the data that arrives in a formData and then if everything is ok I make the POST to my back.My problem is that from the action I can't access anything related to the client (quite slow of me to realise this just now hahahaha), either
localStorage or sessionStorage to access the token and make the request. Now this leaves me with the question of whether requests should be made in the action or am I missing the point, as any kind of request with
Authorization is complicated unless you have a preset token that never expires(?).