facebook / facebook/docusaurus

Add strict client-side routes - always respect presence or absence of a trailing slash

Offen
#8,693 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
feature
Vorherrschende Sprache
TypeScript
Sterne
66.2k
Forks
10k
Ø Merge
1 T. 3 Std.
Gemergte PRs (30 T.)
52

Beschreibung

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#issues).

### Prerequisites

- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the `npm run clear` or `yarn clear` command.
- [X] I have tried `rm -rf node_modules yarn.lock package-lock.json` and re-installing packages.
- [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).

### Description

When running a site with `trailingSlash: false`, the build creates an html file per page, then when going to that page URL with an added slash (e.g. `site.com/page/`) the server returns a page not found with a 404 code as expected, but the client router is re-rendering the page as if the slash wasn't part of the URL, which in turn causes links to break.

### Reproducible demo

https://stylable.io/docs/guides/migration-v3/

### Steps to reproduce

1. open network to see 404 response (you can sometimes see the 404 flickers)
2. see page is re-rendered with the content as if the slash was not there
3. go to the `Runtime reference` link and click it to see a broken link
4. change the initial url to be without the slash and everything works fine

### Expected behavior

Client should respect 404 page and either keep the 404 as is or redirect the URL to remove the slash

### Actual behavior

Client is "fixing" routing without actually redirecting the URL resulting in broken links and 404 flicker

### Your environment

- Public source code: https://github.com/wixplosives/stylable.io
- Public site URL: https://stylable.io/
- Docusaurus version used: 2.3.1

### Self-service

- [ ] I'd be willing to fix this bug myself.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.