Skip to content
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

fix(v2): redirect plugin should emit redirect files with lower precedence than redirect target #5085

Merged
merged 2 commits into from
Jun 29, 2021

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Jun 29, 2021

Motivation

Fixes #5055

On beta.2, the redirects plugin started to emit different redirect filenames for fromExtensions: ["html"] + trailingSlash: undefined.

beta.0

  • Real file: build/v1.21.x/getting-started/overview/index.html
  • Redirect file: build/v1.21.x/getting-started/overview.html/index.html

beta.2

  • Real file: build/v1.21.x/getting-started/overview/index.html
  • Redirect file: build/v1.21.x/getting-started/overview.html ❌

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 explicit trailingSlash 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

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Jun 29, 2021
@slorber slorber requested a review from lex111 as a code owner June 29, 2021 16:43
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 29, 2021
@netlify
Copy link

netlify bot commented Jun 29, 2021

✔️ [V2]

🔨 Explore the source changes: 395c20b

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60db51c0c006d80007affa5f

😎 Browse the preview: https://deploy-preview-5085--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Jun 29, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 94
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5085--docusaurus-2.netlify.app/

@github-actions
Copy link

github-actions bot commented Jun 29, 2021

Size Change: 0 B

Total Size: 601 kB

ℹ️ View Unchanged
Filename Size
website/build/assets/css/styles.********.css 87.7 kB
website/build/assets/js/main.********.js 415 kB
website/build/blog/2017/12/14/introducing-docusaurus/index.html 66.5 kB
website/build/docs/introduction/index.html 235 B
website/build/index.html 31.3 kB

compressed-size-action

@slorber slorber merged commit a78e4f1 into master Jun 29, 2021
@slorber slorber deleted the slorber/revert-redirect-plugin-output-file-behavior branch August 17, 2021 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite network requests/refresh loop while accessing docs
2 participants