Skip to content
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

Redirects do not work #684

Closed
NetOpWibby opened this issue Oct 2, 2018 · 3 comments
Closed

Redirects do not work #684

NetOpWibby opened this issue Oct 2, 2018 · 3 comments

Comments

@NetOpWibby
Copy link

Expected behavior

emit("replaceState", "/") redirects a user to the specified URL.

Actual behavior

Nothing happens. Even the official site has this issue.

Steps to reproduce behavior

Put emit("replaceState", "/") inside a route and be sad that you don't get redirected.


I'm using fastify for the server so I'll try intercepting choo to make redirects happen via fastify instead. I'd rather do it programmatically in choo though.

@NetOpWibby
Copy link
Author

This is the way I am doing redirects now: https://github.com/lbryio/lbry.tech/blob/master/app/modules/redirect-404.js

@goto-bus-stop
Copy link
Member

Yea this is a problem we've had for a while. You can wrap the emit call inside a setTimeout(() => {}, 0) to work around it for now

@NetOpWibby
Copy link
Author

So the first instance of the redirect is here: https://github.com/lbryio/lbry.tech/blob/master/app/views/redirect.js#L51

// relevant portion
if (!fs.existsSync(`./documents/${path}.md`))
  return redirect404(state, emit); // when I add emit here, it does get passed to my redirect-404.js file   
// ...but replacing the HTML in that file with the code below results in nothing
setTimeout(() => {
  emit("replaceState", redirectUrl);
}, 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants