next-runtime
next-runtime copied to clipboard
Fix trailing slashes with an edge function
By default Next.js will redirect urls with trailing slashes to their counterpart without a trailing slash. For example /about/
will redirect to /about
. This has caused issues (see below).
@ascorbic created a proof of concept to add or remove trailing slashes in an edge function. This can be used to enable or disabled trailing slashes based upon the Next.js configuration.
Documentation
https://github.com/ascorbic/slash-edge https://nextjs.org/docs/api-reference/next.config.js/trailing-slash
Related Issues
#1329 #998 #1144 #1788
From @ascorbic
This can probably wait until the Edge router is done.
Highly needed due to SEO requirements. Please don't forget
We won't @mike-essen. It'll roll out with our work on edge routing. 👍
Is there any ETA on the work on edge routing? 👍
Not yet @PFJoey. We'll keep you updated as we know more.
What is the status on this one?
@hk86 we are currently working on a new edge router that will allow us to handle more complex routing cases and will include better trailing slash handling. in the meantime you can use the following edge function to add or strip trailing slashes on static pages https://github.com/ascorbic/slash-edge
Any idea about when this is going to be resolved?
I have fixed some issues with ascorbic's functions that handles querystrings and _redirects
The team at Netlify have now released the new v5
Next.js runtime which has support for both pages and app router, on-demand and time-based revalidation, automatic fine-grained cache control, and automatic image optimization using Netlify's image CDN. This issue should be fixed in the new runtime.
You can find the documentation and additional information here: Next.js on Netlify
The v4
runtime is now in the maintenance support phase with no new features being added. Occasional bug fixes and security patches will be applied when needed.
Thanks!