Back

After Giving Corrrect user token , my backend says invalid jwt

  • 0
  • Web
Shubham
8 Mar, 2024, 11:16

useEffect(() => { const fetchData = async () => { try { const userToken =JSON.parse( localStorage.getItem("cookieFallback")); const token=userToken[a_session_${process.env.REACT_APP_PROJECT_ID}] console.log(token) const config = { headers: { Authorization: Bearer ${token} } }; const response = await axios.post('http://localhost:3001/dashborddata/',null,config); console.log(response.data); } catch (error) { console.log(error.message); } };

TypeScript
fetchData();

}, []);

TL;DR
Developers are encountering an 'invalid jwt' error in the backend even after providing the correct user token. The issue seems to be related to JWT authentication. Make sure the token is correctly parsed and passed in the Authorization header. Double-check the token generation and verify that the token provided is valid and not expired.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more