-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query strings always consumed by Amplify Auth after invoking getCurrentUser() #13096
Comments
HI @shavez-btl thank you for opening this issue, I've been doing some testing here to try and reproduce this issue however the Can you provide a bit more context, specifically on how your router is structured and when/how you are calling Also have you tested by directly going to a route and manually appending the |
My application is quite simple and it goes like this: <App>
<Routes>
// Unauthenticated routes
<Route>
{publicRoutes.map((route, idx) => (
<Route
path={route.path}
element={
<NonAuthLayout>
{route.component}
</NonAuthLayout>
}
key={idx}
exact={true}
/>
))}
</Route>
// Authenticated routes
<Route>
{authProtectedRoutes.map((route, idx) => (
<Route
path={route.path}
element={
<AuthProtected>
<VerticalLayout showFooter={route.showFooter ?? true}>
{route.component}
</VerticalLayout>
</AuthProtected>
}
key={idx}
exact={true}
/>
))}
</Route>
</Routes>
</App> In this const publicRoutes = [
{ path: "/logout", component: <Logout /> },
{ path: "/login", component: <Login /> },
{ path: "/forgot-password", component: <ForgetPasswordPage /> },
]; const authProtectedRoutes = [
{ path: "/dashboard", component: <DashboardEcommerce /> },
{ path: "/subscription", component: <Subscription /> },
{ path: "/recommendations", component: <RecommendationPage /> },
//Error
{ path: "*", component: <Error404 /> },
{
path: "/",
exact: true,
component: <Navigate to="/dashboard" />,
}
]
Yes, I have tested and amplify consumes the query string. In fact this is valid for any query string and not just |
I'd like to suggest that once a fix is found for this issue that it be backported to v5 if possible. Our team, and I assume perhaps others, can't easily upgrade to v6 due to the webpack version change. |
Hi @timharsch, would it be possible for you to test if the issue goes away if you remove getCurrentUser()? For me the issue is present on all auth protected routes and removing call to getCurrentUser() fixes the issue. |
@shavez-btl Looking at the source code for |
You mentioned removing the Have you tried testing to see if setting state in How are you navigating the user to protected pages with query strings? Is it from one page to another, updating the url from the same page, etc? |
Fixed it! Turns out Since it was ending in error, the app was redirecting user to I think some of us are facing this issue because there was a change in how Amplify is configured in v6. I am closing this issue for now. |
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
Amplify CLI
Environment information
Describe the bug
I am trying to implement Outh2 Authorization Code flow for getting user consent to access Microsoft account. When requesting the Authorization Code, microsoft redirects to my app with the query string "code". This query string is caught by aws-amplify/auth.
Adding any query string to the url is consumed by Amplify.
If I remove the
getCurrentUser()
function which is invoked whenever auth protected routes are opened, the issue goes away. So it seems likegetCurrentUser()
is triggering some code that then listens for all query parameters.Also, pages not protected by auth don't have this issue at all.
It is important to note that I am not using
signInWithRedirect()
, so there is no reason for Amplify to listen for query strings.Expected behavior
Amplify shouldn't consume query strings
Reproduction steps
react-router-dom
and usegetCurrentUser()
function fromaws-amplify/auth
.Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: