Skip to content

Fix trailing slashes with an edge function #1448

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

Closed
MarcL opened this issue Jul 5, 2022 · 10 comments
Closed

Fix trailing slashes with an edge function #1448

MarcL opened this issue Jul 5, 2022 · 10 comments
Labels
priority: medium type: feature code contributing to the implementation of a feature and/or user facing functionality v4 Issues related to the v4 Next.js runtime

Comments

@MarcL
Copy link
Contributor

MarcL commented Jul 5, 2022

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

@MarcL MarcL added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Jul 6, 2022
@nickytonline
Copy link

From @ascorbic

This can probably wait until the Edge router is done.

@mike-essen
Copy link

Highly needed due to SEO requirements. Please don't forget

@MarcL
Copy link
Contributor Author

MarcL commented Nov 16, 2022

We won't @mike-essen. It'll roll out with our work on edge routing. 👍

@PFJoey
Copy link

PFJoey commented Nov 19, 2022

Is there any ETA on the work on edge routing? 👍

@MarcL
Copy link
Contributor Author

MarcL commented Nov 21, 2022

Not yet @PFJoey. We'll keep you updated as we know more.

@hk86
Copy link

hk86 commented Feb 6, 2023

What is the status on this one?

@orinokai
Copy link
Contributor

@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

@jessicaribeiroalves
Copy link

Any idea about when this is going to be resolved?

@devotox
Copy link

devotox commented Nov 3, 2023

I have fixed some issues with ascorbic's functions that handles querystrings and _redirects

Netlify Edge Functions

@MarcL MarcL added v4 Issues related to the v4 Next.js runtime and removed Ecosystem: Frameworks labels Mar 13, 2024
@MarcL
Copy link
Contributor Author

MarcL commented Apr 23, 2024

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!

@MarcL MarcL closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium type: feature code contributing to the implementation of a feature and/or user facing functionality v4 Issues related to the v4 Next.js runtime
Projects
None yet
Development

No branches or pull requests

8 participants