question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

  1. For a local version I ran docusaurus start.
  2. 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:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
slorbercommented, Aug 31, 2020

I’ve opened a dedicated issue: https://github.com/facebook/docusaurus/issues/3372

1reaction
marikanercommented, Aug 31, 2020

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 😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

htaccess inconsistent redirect behavior - Stack Overflow
When I type www.hhoprofessor.com/bak/random_file_name, it redirects to www.hhoprofessor.com/file_not_found. This is the correct behavior. When I ...
Read more >
Inconsistent behavior among browsers when clicking on buttons
I noticed browsers were inconsistent in how they handle a click on a button element. Some browsers choose to focus on the button....
Read more >
Redirect to 'Recently worked on' page is confusing after ... - Jira
It feels like an incredible poor implementation to have to have users click "Back" twice to get to their previous page, and also...
Read more >
How to Troubleshoot Browser Content Redirection
This article describes the Citrix policies required to configure Browser Content Redirection feature, and provides general troubleshooting guidelines.
Read more >
Differential Reinforcement of Incompatible Behavior
Differential reinforcement of incompatible behavior (DRI) is a weakening ... Treatments incorporating a redirection component led to a mean reduction of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found