skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. The first lint – https://sample-project-app-router.javimartinez.es/, actually performs client side navigation (See GIF below).

    enter image description here

    The second red crossed link throws 502
    enter image description here

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search