JsonWebTokenError: jwt must be provided

I attaching the backend and frontend both code snippet.
No description
No description
12 Replies
vic
vic2w ago
Make sure the /signin sends response jwt token data Guess the error in /signin function in backend console logs the response variable and check it contains the token
Ashwani
Ashwani2w ago
@vic It is passing the auth after sign in. But When I redirect the page to "/todo" in frontend, it refreshes the page hits the todo api in the backend again and fails to get jwt. Bcoz I can't send jwt with window.location.href = "http://localhost:3000/todo";
No description
No description
Ashwani
Ashwani2w ago
Please somebody help. I have been googling and gpting, but could get the desired result.
vic
vic2w ago
Why u need to send the token ? If u set the token in localstorage , u can access in localstorage
Ashwani
Ashwani2w ago
But I can't access localStorage in Node js where the auth runs.
vic
vic2w ago
Then use cookies
vic
vic2w ago
Stack Overflow
How to store jwt token in localStorage and send it back to the serv...
I have read many articles in stackoverflow and have seen lots of youtube videos, but failed to find the example code which is demonstrating about the flow of saving jwt to localstorage - send back to
vic
vic2w ago
Take a look at this Also storing jwt token in localstorage is not a good practice
Ashwani
Ashwani2w ago
Right. Just a beginner's project. Will use lastest processes for auth.
vic
vic2w ago
Did u try see the headers in /todo path To check whether it has token
Ashwani
Ashwani2w ago
It is available in req headers, checked on browser. I think maybe I am not following the right way to land on todo page after signin.
vic
vic2w ago
So token is available Try console log in /todo path U need to use spilit the token
Want results from more Discord servers?
Add your server