I tried multiple approaches, but eventually found that the root cause was a "Page Not Found" error.
In my case, the route name in the code was sign-in
, but on GitHub, I had accidentally pushed it as Sign-in
. Since Next.js is case-sensitive with routes, this mismatch caused the deployed version on Vercel to fail.
After changing the route name to all lowercase (sign-in
) in the main branch and redeploying, everything started working fine