Cognito redirecting to localhost on production amplify #2771
Replies: 3 comments 3 replies
-
Unfortunately this is most certainly a misconfiguration of the NEXTAUTH_URL environment variable. Try to double check by printing it out for example. We only default to localhost, if we didn't find the |
Beta Was this translation helpful? Give feedback.
-
Hey, I'm facing the same issue, I know it's been a while but did you guys manage to fix it? |
Beta Was this translation helpful? Give feedback.
-
I was able to fix this by adding this line in my build settings - AWS Amplify. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
My application is not redirecting to a correct url when going up in amplify,
It's pointing to localhost: 3000
My environment variable is correct:
NEXTAUTH_URL = https://main.*******.amplifyapp.com
And my callback url is set up correctly in AWS Cognito:
https://main.*******.amplifyapp.com/api/auth/callback/cognito
I'm using the next 11
And actual version of "next-auth": "^3.29.0"
On login the next redirects to localhost:3000/api/auth/signin/cognito
How to reproduce ☕️
`
import { signIn, signOut, useSession } from 'next-auth/client'
export default function HomePage() {
const [session, loading] = useSession()
if (loading) return
return (
<>
{!session && (
<>
Não logado
<button
onClick={() =>
signIn()
}
>
Entrar
</>
)}
{session && (
<>
Logado como {session.user.email}
<button onClick={() => signOut()}>Sair
</>
)}
</>
)
}`
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Beta Was this translation helpful? Give feedback.
All reactions