Inconsistent `Redirect` component behavior
See original GitHub issue🐛 Bug Report
Running docusaurus with redirects locally and on Github Pages produces different results. I have a markdown file that is supposed to redirect to another page:
---
id: redirect-to-a
---
import {Redirect} from '@docusaurus/router';
<Redirect to='a' />
When running locally requesting <path>/redirect-to-a
in a browser redirects me to <path>/a
which is exactly what I want. On Github Pages it (sometimes) redirects me to <path>/redirect-to-a/a
which gives me a 404. I have had multiple occasions where this worked for one page, but not the other.
Have you read the Contributing Guidelines on issues?
yes
To Reproduce
- For a local version I ran
docusaurus start
. - For the remote version I understand that
docusaurus deploy
is used.
Expected behavior
Local and remote redirect behavior is the same.
Actual Behavior
Local and remote redirect behavior differ.
Your Environment
- Docusaurus version used: 2.0.0-alpha.61
- Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Chrome 84.0.4147.135 (Official Build) (64-bit) (although we also tried other browsers),
- Operating system and version (desktop or mobile): macOS 10.15.6
Reproducible Demo
I will give my best to provide this soon. I am a total newbie to docusaurus, so it will take me some more time to be able to reproduce this. In the mean time, maybe somebody has an idea as is.
One more thing that I tried was running docusaurus build
and then docusaurus serve
but it seems that this does not help me understand the issue because the resulting site did not have any css and redirects didn’t redirect anywhere.
Workaround
Btw, I also found a workaround that might be helpful to other encountering this, although I am not 100% happy with it, because I need to know the <path>
for it:
---
id: redirect-to-a
---
import {Redirect} from '@docusaurus/router';
import useBaseUrl from '@docusaurus/useBaseUrl';
<Redirect to={useBaseUrl('<path>/a')} />
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
I’ve opened a dedicated issue: https://github.com/facebook/docusaurus/issues/3372
So after investigating this a bit, I am pretty sure that this is related to these existing issues: https://github.com/facebook/docusaurus/issues/2654, https://github.com/facebook/docusaurus/issues/2394, https://github.com/facebook/docusaurus/issues/2134. Therefore I’ll close this as a duplicate and hope that these issues will be addressed 😊