To fix the 404 error with NextAuth, just add an AUTH_SECRET in your Environment Variables Generate it with:
openssl rand -base64 32
Then add it in ( Environment Variables in Vercel Dashboard)
AUTH_SECRET=your_generated_secret_key
Redeploy it and the issue should be resolved