We have a website build using Next.js 10.x and hosting it on Netlify. It’s a public repo https://github.com/livechat/livechat-public-docs and a Netlify URL is https://livechat-public-docs.netlify.app.
I tried to use the new library to handle loading MDX site content. In this case, all routes are defined dynamically. Here is my pull request and deploy preview.
However, Netlify added some weird redirect that doesn’t let me to keep trailing slash on the base path of our site. This redirect doesn’t exist when I run the project locally. It’s a big problem for us, because we have defined a redirect that adds a trailing slash to the site (because of SEO reasons). It all combined causes infinity loop and
Too Many Redirects error.
How can I get rid of that Netlify redirect? As far as I investigated the problem, enabling Pretty URLs or AO doesn’t seem to help.
Netlify doesn’t add any such redirect by itself. Could you provide an example URL with the redirect you mentioned?
Also, note that Next.js 10 is not a version that we provide support for anymore.
Take a look at mentioned deploy preview. Every time I try to enter https://deploy-preview-1174–livechat-public-docs.netlify.app/ with a trailing slash, I get redirected to https://deploy-preview-1174--livechat-public-docs.netlify.app without it.
Thanks for your reminder about Next version. We have plans to update it.
Hi, @Artur_Fracala. I’m not sure I understand. It is possible to have a URL without a slash after the domain name. It is a requirement of the HTTP standard that a minimum path of
/ must be used.
I also do not see this when making an HTTP request for that URL:
$ curl --compressed -svo /dev/null https://deploy-preview-1174--livechat-public-docs.netlify.app/ 2>&1 | egrep '^(<|>)'
> GET / HTTP/2
> Host: deploy-preview-1174--livechat-public-docs.netlify.app
> user-agent: curl/7.79.1
> accept: */*
> accept-encoding: deflate, gzip
< HTTP/2 200
< age: 2
< cache-control: public, max-age=0, must-revalidate
< content-encoding: gzip
< content-type: text/html; charset=UTF-8
< date: Tue, 28 Jun 2022 08:51:26 GMT
< etag: "8fef66da4daed7c55f5cf9f04797bd4a-ssl-df"
< server: Netlify
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< vary: Accept-Encoding
< x-bb-except: Cookie=__prerender_bypass,__next_preview_data
< x-nf-request-id: 01G6MR463YXWTB4GSQMNFCXFCM
< x-robots-tag: noindex
That show a 200 response and not a redirect. The path is definitely
/ as shown on this line:
> GET / HTTP/2
Would you please confirm the URL you see this happening for? Also, if you have the
x-nf-request-id HTTP response header for an incorrect response, that will help us to find it as well.