Hosting environments that add a trailing back slash break page links
See original GitHub issue🐛 Bug Report
Hosting setups that add a trailing back slash to urls break all inter-site links on the page.
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
- Create a new site using
npx @docusaurus/init@next init test-site classic - Create two new sub folders in docs called
aandb - Add attached file
a.mdtoafolder, andb.mdtobfolder. - Replace
sidebar.jswith attached version. - run
npm run buildto generate the flat site. - Load the site in any browser by navigating directly to the url of page
a:http://127.0.0.1:8080/docs/a/a - Click the link
Link to page "b"
Expected behavior
Page b should load.
Actual Behavior
Page Not Found page.
Your Environment
- Docusaurus version used: 2.0.0-alpha.48
- Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Safari 13.0.5 (15608.5.11), Chrome 80.0.3987.132, Firefox 73.0.1
- Operating system and version (desktop or mobile): macOS 10.15.3 (19D76)
Reproducible Demo
(Paste the link to an example repo, including a siteConfig.js, and exact instructions to reproduce the issue.)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:12 (2 by maintainers)
Top Results From Across the Web
When should I use a trailing slash in my URL?
The trailing slash seems to mitigate any concerns, allowing the page to rank in search engines and get by virus checkers.
Read more >Should You Have a Trailing Slash at the End of URLs?
A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. But should you...
Read more >Trailing Slashes in URLs – What is the Preferred Style?
With the trailing slash, the server assumes that the request is a directory and not a file. The result will either be a...
Read more >Deploying to Github Pages? Don't Forget to Fix Your Links
Root-relative links are links that start with a forward slash ( / ). When clicked, a root-relative link ignores the path location of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

My current way to workaround that:
static/js/fix-location.jswith:docusaurus.config.js:I’m having the same issue, it breaks URL navigation due to HTTP proxy services. I use `Nginx in the docker, when I directly open a link without trailing slash, it redirects to HTTP domain with the port used in Nginx. Since we don’t run on 443 port it breaks the public link.
For example, if I try to open
https://domain.com/ait redirects tohttp://domain.com:8080/a/and it fails to load the page. But if you openhttps://domain.com/a/it works fine. Does anyone have the same issue?