You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
didemkkaslan opened this issue
Jan 12, 2024
· 3 comments
Assignees
Labels
AuthRelated to Auth components/categoryHostingIssues related to Amplify HostingNext.jspending-responseIssue is pending response from the issue requestorquestionGeneral questionSSRIssues related to Server Side Rendering
I've done the steps for migrating to amplify v6. Have an issue with authentication handled by middleware. Sometimes signIn gets stuck and the login page is frozen. This only happens on production. Actually signIn works correctly so I can see isSignedIn is equal to true and nextStep.signInStep is DONE. but still its somehow stuck
And I don't know if its normal but console logging the request.nextUrl.pathname in middleware is like below. Its being called for every route even if I only hit /login route.
request.nextUrl.pathname /login
request.nextUrl.pathname /
request.nextUrl.pathname /register
request.nextUrl.pathname /login
request.nextUrl.pathname /meetings
react-i18next:: You will need to pass in an i18next instance by using initReactI18next
request.nextUrl.pathname /meetings
request.nextUrl.pathname /
request.nextUrl.pathname /settings/account
request.nextUrl.pathname /people
request.nextUrl.pathname /tags
request.nextUrl.pathname /library
request.nextUrl.pathname /meetings/1fc12626-80be-45f0-a877-1f2672c6f268
request.nextUrl.pathname /people/664c5993-abe5-46eb-b86e-c5aa907de500
request.nextUrl.pathname /people/698f197a-f3f3-4b1c-bad3-1c0bd6a23192
request.nextUrl.pathname /meetings/1fc12626-80be-45f0-a877-1f2672c6f268/overview
request.nextUrl.pathname /login
request.nextUrl.pathname /register
@didemkkaslan, sorry to hear this is happening after migrating to v6. Just to make sure I understood this correctly, you said that every route is being called via the middleware when you're only trying to sign in via the /login route? Was any of this behavior happening in v5, or only after you upgraded (even if sporadically)?
@cwomack I wasn't using middleware before we had client side auth hoc. I wanted to implement serverside auth but v5 didn't quite work well with middleware so I decided to migrate to v6. Yes you are correct in development everything works well but when deployed ( we use amplify hosting ) middleware is being called for every route initially. When I hit /login route it goes like
/login
/
/register
So I've removed middleware.ts and instead did it for every protected page in getServerSideProps and it works well both locally and prod. But I really want to use middleware to handle this Idk whats wrong
@didemkkaslan, appreciate the patience on a response for this issue. That's great to hear that it is working if the middleware is removed, and it helps isolate the issue to the middleware I think. When you enable the middleware, what is the expected redirect order? And is there more code for the middleware beyond what was provided in the original issue description?
Also, do you have any redirect rules/logic set up through Amplify Hosting by chance?
AuthRelated to Auth components/categoryHostingIssues related to Amplify HostingNext.jspending-responseIssue is pending response from the issue requestorquestionGeneral questionSSRIssues related to Server Side Rendering
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
None
Environment information
Describe the bug
I've done the steps for migrating to amplify v6. Have an issue with authentication handled by middleware. Sometimes
signIn
gets stuck and the login page is frozen. This only happens on production. Actually signIn works correctly so I can see isSignedIn is equal to true and nextStep.signInStep is DONE. but still its somehow stuckAnd I don't know if its normal but console logging the request.nextUrl.pathname in middleware is like below. Its being called for every route even if I only hit /login route.
Expected behavior
signIn should redirect the user to / route
Reproduction steps
// On Login Form Submit
// middleware
Code Snippet
// Put your code below this line.
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: