adrianhajdin / project_mern_memories

This is a code repository for the corresponding video tutorial. Using React, Node.js, Express & MongoDB you'll learn how to build a Full Stack MERN Application - from start to finish. The App is called "Memories" and it is a simple social media app that allows users to post interesting events that happened in their lives.
https://youtube.com/playlist?list=PL6QREj8te1P7VSwhrMf3D3Xt4V6_SRkhu
4.96k stars 1.83k forks source link

Not being able to redirect to the Sign in Page after surfing the site for a long time. #116

Open MatinT-SA opened 2 years ago

MatinT-SA commented 2 years ago

Whenever I log in with a user and then surf the site for a couple of minutes ( like watching different posts, liking them, trying to use pagination and search features and etc...) and then I log out to try logging in with another user, it doesn't redirect me to the "Sign In" page after clicking on its button located in the Navbar but totally that button's functionality works fine whenever I close all the tabs or in other words, the opened window of my browser and re-run the client side in the terminal. But this issue appears again when try to do the same things explained above. If you do all the stuff quickly, you won't observe this issue but of course users want to stay on your application for a long time and NOT for 1 or 2 minutes.

Actually by clicking on the "Sign In" button, it redirects me back to the posts page which is not the expected output. There is no user available in the localStorage and basically it has to redirect me to the /auth path which as I explained, it doesn't work properly in these situations. Keep in mind that it only appears when I surf the application for 5-10 minutes which is an unusual behavior with no doubt. Has anyone faced this issue and if yes, how can I fix that? Thanks.


Edit by the end of May 27th 2023: I've completed the projected and couldn't find any solution utill the end.

rua02me commented 1 year ago

mee too, have u solved it ?

MatinT-SA commented 1 year ago

@rua02me No, unfortunately.

AlexanderSChen commented 1 year ago

In your client App.js file make this change to stop the sign in button from redirecting to /posts and make sure it only redirects to /auth. Hope this helps! component={() => (!user ? <Auth /> : <Redirect to="/posts" />)} /> ==> <Route path="/auth" exact component={Auth} />