JsonWebTokenError: jwt must be provided
I attaching the backend and frontend both code snippet.
12 Replies
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
@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";
Please somebody help. I have been googling and gpting, but could get the desired result.
Why u need to send the token ?
If u set the token in localstorage , u can access in localstorage
But I can't access localStorage in Node js where the auth runs.
Then use cookies
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
Take a look at this
Also storing jwt token in localstorage is not a good practice
Right. Just a beginner's project. Will use lastest processes for auth.
Did u try see the headers in /todo path
To check whether it has token
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.
So token is available
Try console log in /todo path
U need to use spilit the token