ERR_TOO_MANY_REDIRECTS after upgrading to Nextjs v5 runtime from v4

Main Netlify site name: velvety-vacherin-4193fb
Main site URL: https://ameliorate.app/
Docs Netlify site name: ameliorate-docs
Docs site URL: Introduction | Ameliorate

I have my main site set up to proxy my /docs pages to my separate docs site (both deployed via netlify). This worked when I initially set it up, but now it seems that it only works when I go directly to a non-root redirected page.

Specifically, Introduction | Ameliorate now infinitely redirects when redirecting to Introduction | Ameliorate, but a non-root page e.g. Getting Started | Ameliorate still properly redirects to Getting Started | Ameliorate.

I’m suspecting the Nextjs v5 runtime because I’ve run netlify dev locally with the v4.41.3 runtime, observed that the redirect does not infinitely redirect, then manually set to use the v5.1.2 runtime, and reproduced the infinite redirect.

These are my settings in main site’s netlify.toml (as set up by following this Support Guide):

[[redirects]]
  from = "/docs/*"
  to = "https://ameliorate-docs.netlify.app/docs/:splat"
  status = 200

and my docs site just has an empty netlify.toml so that it doesn’t inherit the same redirects as the parent site (they’re in the same repo, and the main site’s netlify.toml is in the repo root).

I’ve also confirmed that the latest deploy log says the v5 runtime is being used, as well as the above redirect config: Netlify App.

Any ideas what might be wrong?

Hi @keyserj,

Thanks for reaching out and welcome back to the Netlify Support Forums!

Sorry to hear about the issue. Reviewing the redirects you posted, with the 200 that is doing a rewrite instead of a redirect is that intended?

Could you try on a test branch:

[[redirects]]
  from = "/docs/*"
  to = "https://ameliorate-docs.netlify.app/docs/:splat"
  status = 301  
  force = true 

The 301 will ensure it’s not a rewrite and is a redirect.

Hey @Melvin ,

Doing a rewrite is intended, so that my docs site is visited through the same URL as my main site (i.e. ameliorate.app/docs instead of ameliorate-docs.netlify.app/docs).

A 301 redirect does look like it’s working without infinite redirecting, but that results in ameliorate-docs.netlify.app/docs in the address bar instead of the desired ameliorate.app/docs.

I was able to fix the problem by adding another redirect rule before my catch-all, to redirect specifically for the root /docs:

[[redirects]]
  from = "/docs"
  to = "https://ameliorate-docs.netlify.app/docs"
  status = 200

[[redirects]]
  from = "/docs/*"
  to = "https://ameliorate-docs.netlify.app/docs/:splat"
  status = 200

hi :wave:t6: thanks for writing back in and sharing your solution with the community. This is helpful for other folks who stumble upon this thread with a similar issue.