facebook / facebook/docusaurus

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

Abierto
#8,693 3 comentarios 1 reacción 0 asignados Ver en GitHub
feature
Lenguaje dominante
TypeScript
Estrellas
66.2k
Forks
10k
Merge medio
1 d 3 h
PR fusionados (30 d)
52

Descripción

### 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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.