#Amplify Auth - Network error

11 messages · Page 1 of 1 (latest)

lone sentinel
#

Hi all,

I'm using Amplify UI Authenticator to handle user login. And I face a weird error when trying to login to the app as show in the picture.

The setup is working well in my teammates machine and our website but doesnt work for me.

I can signup and Cognito also received my identities. But in the NextJS backend, it keep showing this error message and not logging me in.
I have also received the code from the Cognito. But the status of the Authenticator is stuck as configuring after I logged in.

Does any know how to debug this further?
Thank you in advance.

grim parcel
#

Are you trying in local? if yes, is your sandbox running?

lone sentinel
#

Yes, im trying it in local and the sandbox is running normally.
I digged a bit and seems like it caused by the fetchAuthSession which I called in the middleware. But I'm failed to try getting more information about this error. All I received is just "Network error" 🥲

torn oak
#

Hi @lone sentinel how are you handling the error in the try/catch?

lone sentinel
#

@torn oak Hi, this is the code of my try/catch

const userContext = await runWithAmplifyServerContext({
    nextServerContext: { request, response },
    operation: async (contextSpec) => {
      try {
        const session = await fetchAuthSession(contextSpec, {})
        let user
        if (session.userSub) {
          [. . .]
        }
        
        return {
          authenticated: session.tokens !== undefined, 
          [. . .]
        }
      } catch (error) {
        console.log(error)
        return {authenticated: false, [. . .]}
      }
    },
  })
honest surge
#

@lone sentinel

#

u solved?

#

i have same problem

#

@covert stag

lone sentinel
#

@honest surge yeah, I saw your issue. But unfortunately, it still not work for me while it works perfectly in my teammate's machine 🥲