New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Trailing slash not working #1329
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
I'm experiencing the same issue with ISR pages. The |
I've updated the issue with a public repository and a public deployed site with a static, a SSG and a SSR page. The only page where the trailing slash is being added is in the SSR page. |
Anyone can check this? |
I'm facing the same problem in netlify, works correctly in vercel. directly going to i was able to stop 301 redirect by enabling pretty urls in asset optimization but the same page is duplicated in 2 different urls i.e. |
Hi all! First off, thanks @scajal for the initial issue submission and the repro and thanks @gnevin and @shubhendusaurabh for the additional information. Unfortunately this is not a bug with the plugin but is behaviour resulting from our logic on the Netlify CDN aimed at keeping site performance high by maximizing the cache hit rate. I've raised this issue with the related team and confirmed that this behaviour is not configurable, but have asked about further investigation into ways to mitigate or address the SEO issues that are being caused as a result of the page duplication that's been mentioned here. I had investigated trying to create an edge function that would've supported this behaviour as a workaround, but unfortunately that kind of redirect causes an infinite loop because the resulting paths are essentially the same. Related Netlify docs for those interested in reading a bit more can be found here Because this is an issue resulting from behaviour with the CDN and not the plugin, this bug will be closed as 'won't fix/do', but please don't hesitate to ask any follow up questions here. |
I've made a quick demo of using edge functions to strip the trailing slashes. I will add an equivalent to add the slashes. It works around the different ways the CDN defines the canonical URL. We will add this to the plugin so it works by default according to the next config, but for now you can add it manually. |
Hi @ascorbic, your solution is not working for me, it throws ERR_TOO_MANY_REDIRECTS in the browser. |
@scajal can you try with an updated version? |
thank you @ascorbic ! your solution works for our Next.js app on Netlify |
Which updated version should I use? I am also facing the same redirects too many times issue |
Hey, @ascorbic, I'm unsure if there's been an update on Netlify's side, but I am getting the redirect issue with top-level pages; I also see this on your demo. |
Summary
The option
trailingSlash: true
is not working when deploying a site.The site also has
Pretty URLs
option activated in the deploy settings.Some links work with the slash (but have both versions, which is bad for SEO).
The only pages that are working with trailing slash are server side pages.
Steps to reproduce
A link to a reproduction repository
https://github.com/scajal/netlify-test
Plugin version
4.7.0
More information about your build
netlify.toml
)What OS are you using?
No response
Your netlify.toml file
`netlify.toml`
# Paste content of your `netlify.toml` file here
Your public/_redirects file
`_redirects`
# Paste content of your `_redirects` file here
Your
next.config.js
file`next.config.js`
Builds logs (or link to your logs)
Build logs
Function logs
Function logs
.next JSON files
generated .next JSON files
The text was updated successfully, but these errors were encountered: