full-stack-with-react-and-spring-boot
full-stack-with-react-and-spring-boot copied to clipboard
Missing axios.interceptors.request config after refresh
Version I'm using the entire project with the backend and frontend from the github repository
Test Case full-stack-with-react-and-spring-boot project backend & frontend clone
Steps to reproduce -Get logged in -List todos page -Check that jwt is being sending into the request as typically -Refresh the page (CTRL+R or F5) -Check that jwt is no longer being sent in the request
Expected Behavior Persist the token header configuration that was set in axios.interceptors.request after every event as refresh page.
Actual Behavior The axios.interceptos.request configuration is getting cleared after refreshing the page so, the request(GET, POST, DELETE) that works with the auth token will not work anymore.

Is there anyway to persist the token auth? or keep the axios.interceptors?
Hey, I got the same problem, have you found a solution yet?
I spent a whole day trying to debug this problem and I encountered your post, thanks for letting me know that I am not alone.
@rayljc I found the solution, sorry thought that no one is following this post so I didn't post.
You can just store the session token by:
AuthenticationService.js
sessionStorage.setItem(..)
And in AuthenticatedRoute.jsx modify to something like this:

@rockmanvnx6 Thanks a lot for replying / helping me out, I would definitely try it and wish you a great day.
Hi @rockmanvnx6 ,
just want to let you know that your method works for me, even though I use basic authentication instead of JWT. (still, I encounter the refreshing issue.)
Below are the screenshots of my codes:

And it works! Thanks again for your help.
It seems to me that we also should remove "USER_TOKEN" in AuthenticationService in "logout" method.