fix(v2): redirect plugin should emit redirect files with lower precedence than redirect target #5085
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #5055
On beta.2, the redirects plugin started to emit different redirect filenames for
fromExtensions: ["html"]
+trailingSlash: undefined
.beta.0
beta.2
This leads to infinite loops when hosted on Netlify, as it picks in priority the redirect file.
This PR restores the previous redirects plugin behavior and emit files such as
overview.html/index.html
, which are generally served by static hosts with lower priority (and nobody complained about that so far)Note: using
fromExtensions: ["html"]
with Netlify is useless in the first place (it already redirects from that extension server-side), and we now recommend setting an explicittrailingSlash
for Netlify, so this issue should not affect a lot of users.Note: it's unlikely the filename pattern the plugin emit will work with 100% of the hosts for 100% of the redirects. This is a best-effort until another edge case is found, as each host/tool has a different behavior (see https://github.com/slorber/trailing-slash-guide)
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
yes
Related PR
Revert change attempted in #4988 where the redirect filenames try to respect the
trailingSlash
config => looks like a bad idea