Closed usullu closed 8 months ago
Hey, @usullu 👋 and thanks for opening this issue. After looking at the error you referenced, it seems you're trying to call the signIn
API in a server action. That isn't supported yet, but we do have feature requests in the repo for this such as #11598.
Additionally, you can refer to the Supported API's for Next.js server-side usage section of the docs to check which ones would work for server side actions. Hopefully that helps clarify why these errors are being thrown, and definitely give that linked feature request a comment or upvote to help it gain traction!
Hey @cwomack, you are my hero! I am trying to solve this problem since two days and you solve it in minutes. Thank you very much!
After using client components without server actions it works like native.
Nevertheless the possibility to signin on the server would be a game changer.
@usullu glad the comment from @cwomack was able to get you resolved! I'll go ahead and close out this issue as we are tracking the feature request of authenticating on the server side on this issue - https://github.com/aws-amplify/amplify-js/issues/11598
Thanks!
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
Amplify Gen 2 (Preview)
Environment information
Describe the bug
No SSR -> I cannot see on the middleware that the use is logged in
with SSR -> I get an error saying that the user has to be signed in to use the api (to signin)
Expected behavior
Hello,
I have a strange bug on using sign in with the new amplify v6.
The registration is checked by the middleware
middleware.ts
If I use the Authenticator from @aws-amplify/ui-react everything works as expected.
Now I try to use a custom server component for the signin flow:
auth/login/page.tsx
Anmelden
If now I try to login, I get the Error:
error signing in UserUnAuthenticatedException: User needs to be authenticated to call this API.
andunderlyingError: undefined, recoverySuggestion: 'Sign in before calling this API again.', constructor: [class AuthError extends AmplifyError]
When I change the line Amplify.configure(config, {ssr: true}); to Amplify.configure(config); then it is a success and the signInStep: 'DONE' but the middleware says to authenticated false and redirects me everytime back to the login page.
What am I doing wrong?
The custom signup component is working without a problem.
Reproduction steps
Code Snippet
Log output
aws-exports.js
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
amplify/auth/resource.ts
amplify/backend.ts