'Getting 403 error while trying to logout current user and login another user, but after manual page refresh page is working again, why?

My website is built using the React library, and I use the JSON Web Token mechanism to send data securely from server to client. When I visit my product page, everything is good, however when I click logout and try to login again with new user information, the accessToken is changed, and the product page displays FULL WHITE(no data load), and in the console 403 forbidden error consoled. However, when I reload the website, the products appear as before. I tried to set window auto-reload when redirected to the product page, but that thing didn't satisfy me.

From the experts, I want to know if there has a better solution, please.

THANKS



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source