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 and App Router, if the app is accessed locally (App or Pages router), through (App or pages router) Vercel or with nginx and Pages router, the soft navigation of the SPA works.
I can confirm it still fails with latest canary and also since at least v13.
This is my nginx config:
location / {
proxy_pass <Vercel Vanity URL or NextJS built-in server in localhost>
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host <Vercel Vanity URL or NextJS built-in server in localhost>;
proxy_ssl_server_name on;
proxy_cache_bypass $http_upgrade;
}
You can check both behaviours with this sample project:
❌ Reverse proxy to Vercel project using App Router -> doing full page refresh
https://sample-project-app-router.javimartinez.es/
✅ Reverse proxy to Vercel project using Pages Router -> working (soft-navigation)
https://sample-project-pages-router.javimartinez.es/
❌ Reverse proxy to self-hosted project using App router (NextJS built-in server) -> doing full refresh
https://sample-self-hosted-app-router.javimartinez.es/
✅ Reverse proxy to self-hosted project using Pages router (NextJS built-in server) -> working (soft-navigation)
https://sample-self-hosted-pages-router.javimartinez.es/
✅ Vercel vanity url to Vercel project using App Router -> working (soft-navigation)
https://sample-project-javiermartinz.vercel.app/
✅ Vercel vanity url to Vercel project using Pages Router -> working (soft-navigation)
https://sample-project-pages-router-javiermartinz.vercel.app/
✅ NextJS built-in production server running in local (Pages or App router) -> working (soft-navigation)
next build && next start
and access to http://localhost:3000
2
Answers
This link: https://sample-project-app-router.javimartinez.es/ is doing soft Navigation not full page reload.
It seems you have a problem with your browser or firewall.
The first lint – https://sample-project-app-router.javimartinez.es/, actually performs client side navigation (See GIF below).
The second red crossed link throws 502
Next.js official docs doesn’t seem to describe nginx config. However, It seems that there is some issue with the async server components being rendered on server side.