-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
Hosting environments that add a trailing back slash break page links #2394
Comments
@littlespex are you sure the browser is adding that slash? Try running your site locally and see if the slash gets added. If not, it most likely is your hosting server. FYI I am seeing the same behavior on Netlify (adding the slash, breaking the links) |
I had updated the ticket description earlier to mention the hosting environment instead of the browser. Unfortunately we don’t have admin control over our docs environment and the team that runs it has enabled these url rewrite rules for other reasons. Our current workaround is to revert to docusaurus v1 which works as expected. |
We are having this issue too running on an Azure Webservice. |
Same here, with GH Pages. |
My current way to workaround that:
if (window && window.location && window.location.pathname.endsWith('/') && window.location.pathname !== '/') {
window.history.replaceState('', '', window.location.pathname.substr(0, window.location.pathname.length - 1))
}
scripts: [
{
src: '/js/fix-location.js',
async: false,
defer: false,
}, |
This is as the website deployment 301s to add trailing slashes, and Docusurus does not yet support that. Without one of the two yielding, this workaround strips the trailing slash so the hrefs made still work. Solution pinched from docusurus issue: facebook/docusaurus#2394
This is as the website deployment 301s to add trailing slashes, and Docusurus does not yet support that. Without one of the two yielding, this workaround strips the trailing slash so the hrefs made still work. Solution pinched from docusurus issue: facebook/docusaurus#2394
This is as the website deployment 301s to add trailing slashes, and Docusurus does not yet support that. Without one of the two yielding, this workaround strips the trailing slash so the hrefs made still work. Solution pinched from docusurus issue: facebook/docusaurus#2394
@dotansimha Thanks for the workaround. Anyone else who uses this fix don't forget to include your
|
Hey, I found the original issue description not so easy to understand (particularly that md files are in zip files 🤪 that does not help to scan this issue). To clarify the problem, here's what I understand:
So this bug is only related to using relative links, is that correct @littlespex ? Is it the problem you also encounter @davidhagg @dotansimha @cliedeman ? Or is it something else? We should find a solution to this problem (track #3372), but in the meantime, possible workarounds are:
|
@slorber I believe this issue happens on any link that does not contain a trailing backslash. We had to revert to docusaurus v1, so I no longer have a working example. |
This is as the website deployment 301s to add trailing slashes, and Docusurus does not yet support that. Without one of the two yielding, this workaround strips the trailing slash so the hrefs made still work. Solution pinched from docusurus issue: facebook/docusaurus#2394
In docusaurus/packages/docusaurus/src/client/normalizeLocation.ts But I don't know whether this would break anything else. |
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 |
FYI there is a related issue here: #3372 so I'm going to close this one. I proposed a temporary workaround here: #3372 (comment) Using client-side normalization is not bad but it won't prevent the host to eventually add a useless server redirect to the URL with a trailing slash. I used it successfully on React-Native website:
The PR I linked to contains a plugin that to will prevent the host to add a trailing slash and prevent a useless server redirect. Please try my workaround with your specific hosting env, and report on the other issue if the workaround works or not for your usecase. If the workaround works for everyone, I'll generalize it and add it by default in Docusaurus core, so your feedback is important. |
🐛 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
npx @docusaurus/init@next init test-site classic
a
andb
a.md
toa
folder, andb.md
tob
folder.sidebar.js
with attached version.npm run build
to generate the flat site.a
:http://127.0.0.1:8080/docs/a/a
Link to page "b"
Expected behavior
Page
b
should load.Actual Behavior
Page Not Found
page.Your Environment
Reproducible Demo
(Paste the link to an example repo, including a
siteConfig.js
, and exact instructions to reproduce the issue.)http://littlespex.com/docusaurus/docs/a/a
test-site.zip
The text was updated successfully, but these errors were encountered: