nextjs-lambda icon indicating copy to clipboard operation
nextjs-lambda copied to clipboard

next-auth login() redirection doesn't work

Open adamsh25 opened this issue 3 years ago • 5 comments

Use case: I used the repo below and added next-auth using Cognito provider: https://github.com/plevavas/monorepo https://next-auth.js.org/getting-started/example https://next-auth.js.org/providers/cognito

The redirection to Cognito login does work locally when debugging in vs code

Issue: The redirection to Cognito login does NOT work when deployed with tosladg/[email protected]

adamsh25 avatar Nov 14 '22 12:11 adamsh25

Hey @adamsh25 ! Any chance you might have a logs on your hand? Also, if you say that redirection does not work - do you get some Internal Error? Does not not function at all? Do you get stuck on API route?

sladg avatar Nov 14 '22 12:11 sladg

Hey @sladg I will need to redeploy this test, I will be able to do so over the weekend. Thank you!

adamsh25 avatar Nov 14 '22 17:11 adamsh25

I did replicate the behaviour, tested on Cognito and latest Next-auth. It indeed does not redirect properly. From what I was able to gather around Github, it seems like cookies/headers are not passed properly through Cloudfront, I tried out tweaking Origin Request and Cache policies, but no luck. I wasn't able to find what headers/cookies are used/necessary, it will probably require digging into source code of the next-auth.

Let me know if you find some more info!

sladg avatar Nov 15 '22 08:11 sladg

Might be related to: https://github.com/nextauthjs/next-auth/pull/5561

khuezy avatar Nov 23 '22 22:11 khuezy

@adamsh25 was there any luck resolving this with newest version of Next-auth?

sladg avatar Jan 02 '23 13:01 sladg