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
This works fine on desktop with Metamask (have not tried other wallets). On mobile, after redirecting, the next-auth signout route is called for some reason, and then I am prompted to sign a message again. This is an infinite loop of sign message, redirect, sign message again etc... This issue occurs with both Metamask and Trust Wallet. Curiously, this is not a problem with Uniswap Wallet and Metamask's built in browser.
I have resorted to just doing SIWE with Next-Auth the old fashioned way as a fix because debugging this has been near impossible for me.
Here is my new working onClick handler solution in my client-side sign in button for reference:
asyncfunctionhandleLogin(){constnonce=awaitgetCsrfToken();// import from next-authconstmessageParams={domain: typeofwindow!=='undefined' ? window.location.origin : '',uri: typeofwindow!=='undefined' ? window.location.pathname : '',chains: [mainnet.id,sepolia.id,base.id],statement: 'Please sign with your account',
nonce,};constmessage=formatMessage(messageParams,address);// import from @reown/appkit-siwesignMessage({ message },{// import from wagmionSuccess: async(data)=>{signIn('credentials',{// import from next-auth
message,callbackUrl: '/my-protected-route',redirect: true,signature: data,});},onError: (error)=>{toast({variant: 'destructive',title: 'Uh oh!',description: error.message,});},});}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have tried to enable redirects after signing in with no success.
I am using NextJS + Next-Auth, with the One-Click SIWE solution (with Wagmi) provided by the docs.
I enable redirects in the siweConfig object inside the verifyMessage function as so:
This works fine on desktop with Metamask (have not tried other wallets). On mobile, after redirecting, the next-auth signout route is called for some reason, and then I am prompted to sign a message again. This is an infinite loop of sign message, redirect, sign message again etc... This issue occurs with both Metamask and Trust Wallet. Curiously, this is not a problem with Uniswap Wallet and Metamask's built in browser.
I have resorted to just doing SIWE with Next-Auth the old fashioned way as a fix because debugging this has been near impossible for me.
Here is my new working onClick handler solution in my client-side sign in button for reference:
Beta Was this translation helpful? Give feedback.
All reactions