-
How can I make sure that authentication state is preserved when I open a link in a new tab? I am using Keycloak integration. when I am opening a link that's in a ProtectedRoute in a new tab it's telling that I am not authenticated. Whereas if I simply click on that link in the same browser tab it works as expected. I get the same behavior when I type the URL in the browser's address bar directly as well. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Essentially when you open a new tab or navigate to a URL directly, you are causing the app to reinitialize, which currently resets the auth state. Clicking on a link however, which is using the react router, does not reset the app and maintains current auth. That said, it looks like there might be another config or 2 needed to get automatic sign in to work when the app reinitializes. Please try the steps here: https://github.com/authts/react-oidc-context?tab=readme-ov-file#automatic-sign-in Let me know if that works. |
Beta Was this translation helpful? Give feedback.
-
thanks, it appears to be working for my use case. I'll do some additional testing and share if I find anything odd to report. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Ok, pretty sure I got everything working as expected here: MetroStar/comet-starter#255.
A couple of key points: