I had been looking for a solution for 2 whole days, and after trying literally everything (apart from this one setting), I had to go to Vercel > Project Settings > Build and Deployment Tab > Framework Settings and changed it from 'Other' to 'Next.js'. This FINALLY fixed it for me.