I have a SPA (Single page application) using ReactJS. Currently, I am allowing users to login with Facebook or Google through AWS Cognito with the Amplify console (My site is hosted with Amplify on S3).
My problem is that when a user tries to enter a page that requires login, he is then redirected to the Sign In page (Using react-router-dom v4), then when they log in, they get redirected to Facebook/Google and then redirected back to my site's home page.
I would like to return them to the page the sent them to sign in as this will cause a bad user experience for my users.
The Auth function I use is: Auth.federatedSignIn({ provider: "Facebook" }).
How can I send them back to the page that sent them to the redirect without storing the page in my store as the session refreshes and the store is not maintained?