sst / open-next

Open source Next.js serverless adapter
https://open-next.js.org
MIT License
3.7k stars 111 forks source link

Hitting a non-existent route results in infinite redirect. Same app behaves correctly locally and on vercel. #405

Open ilyastam opened 2 months ago

ilyastam commented 2 months ago

I have a nextjs app on v14, it uses page routing. when I enter a non-existent route (/foobar) - the app 308 redirects to /404/ few dozen times, and then browser cancels the request.

Same app works fine when ran locally with npm run dev or on vercel.

Here is the link to a version deployed with sst: https://d2ia2gbaq4gtdc.cloudfront.net/ Working version on vercel: tripyacht.com

This is the only thing thats stopping me from fully embracing open next, and migrating away from Vercel.

khuezy commented 2 months ago

Hi can you specify the open-next version and exact next version? Can you also set up a min repo?

According to the latest versions pages: https://dqijpnhzoveol.cloudfront.net/foo app: https://d1rjbhcyvwj9a2.cloudfront.net/foo

They both redirect to 404 and does not have an infinite redirect.

ilyastam commented 2 months ago

Thanks!

Next.js v14.2.1 OpenNext v2.3.7

Sorry, not sure what is "min repo", could you please elaborate?

khuezy commented 2 months ago

A minimum reproduction project on github so we can see what's causing the issue.

khuezy commented 2 months ago

@ilyastam can you try upgrading next to 14.2.2, according to the test, it passes: https://discord.com/channels/983865673656705025/1027265626085019769/1230685589926576309

But there might be some edge case in your setup that's causing the infinite loop that we haven't covered. We'll need a reproduction.