Whenever a link is clicked and navigation is fired, the browser does a full refresh instead of soft-navigation. However, this only happens when using nginx, if the app is accesed locally or through Vercel, the soft navigation of the SPA works.
I can confirm it still fails with latest canary and also since (at least) v14. I have been downgrading my NextJS app till that version and the problem still persists.
This is my nginx config:
location / {
proxy_pass https://sample-project-javiermartinz.vercel.app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host sample-project-javiermartinz.vercel.app;
proxy_ssl_server_name on;
proxy_cache_bypass $http_upgrade;
}
You can check both behaviours with this sample project:
❌ Reverse proxy to Vercel -> doing full page refresh
https://sample-project.javimartinez.es/
❌ Reverse proxy to self-hosted (NextJS built-in server) -> doing full refresh
https://sample-self-hosted-project.javimartinez.es
✅ Vercel vanity url -> working (soft-navigation)
https://sample-project-javiermartinz.vercel.app
✅ NextJS built-in production server running in local -> working (soft-navigation)
next build && next start and access to http://localhost:3000
Generated by create next app
Generated by create next app