ascorbic / slash-edge

Banish or add trailing slashes with a Netlify edge function
https://trailing-slash-edge.netlify.app/
2 stars 1 forks source link

URLs are rewriting instead of redirecting #3

Open nickvigilante opened 1 year ago

nickvigilante commented 1 year ago

We have several redirects in place in our docs site: https://www.cockroachlabs.com/docs/_redirects

Here's a sample PR where I demo this: https://github.com/cockroachdb/docs/pull/17482

Here's the deploy preview for the first commit: https://64b54a5e4d48fa000851137c--cockroachdb-docs.netlify.app/docs/managed/quickstart.html

This URL redirects to https://64b54a5e4d48fa000851137c--cockroachdb-docs.netlify.app/docs/cockroachcloud/quickstart.html, which I expect it to do, given that I haven't enabled the edge function.

After I enable it in the second commit: https://64b54ce25e90670007d0bdd8--cockroachdb-docs.netlify.app/docs/managed/quickstart.html

It redirects to https://64b54ce25e90670007d0bdd8--cockroachdb-docs.netlify.app/docs/managed/quickstart, which I expect the .html to be removed from the URL, but I also expect the URL to update from /managed/ to /cockroachcloud/: https://64b54ce25e90670007d0bdd8--cockroachdb-docs.netlify.app/docs/cockroachcloud/quickstart

All of our URLs now seem to do a rewrite/200 when they're on the old URL, which we do not want for SEO purposes. Any way to work around this?

Thank you for making this function!

nickvigilante commented 1 year ago

I actually see that not returning the response allows redirects to process normally, in case anyone runs into this problem in the future. Thanks!