Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Support server-side route redirects to external url #245

Closed
chrisirhc opened this issue Mar 17, 2019 · 2 comments
Closed

Support server-side route redirects to external url #245

chrisirhc opened this issue Mar 17, 2019 · 2 comments

Comments

@chrisirhc
Copy link

chrisirhc commented Mar 17, 2019

Type of issue

Feature request

Description

There seems to be no way to set up redirects (302s) to external urls. I understand this might be to keep consistent behavior with react-router v4's browser redirect behavior. Perhaps we can offer an <ExternalRedirect> component in fusion-plugin-react-router to workaround this?
Alternatively, if there's some way of doing this otherwise, please document it.

Current behavior

Right now, in order to set up an external redirect route, I'm doing this. This method is clearly sub-optimal since the browser is loading the page with a null component just to redirect (and there's no way to leverage 302 status code here):

    <Route
      path={`/go-to-google`}
      render={() => {
        if (__BROWSER__) {
          window.location.href = 'https://www.google.com';
        }
        return null;
      }}
    />

Expected behavior

Support a syntax like:

    <Route
      path={`/go-to-google`}
      render={() => <Redirect to={"https://www.google.com"} />}
    />
@mlmorg
Copy link

mlmorg commented Mar 29, 2019

It seems that react-router does not support this. We don't want to add support on top of react-router into this plugin, since it should just setup and use react-router. Perhaps this could be a ticket on react-router or a different plugin needs to be created.

@mlmorg mlmorg closed this as completed Mar 29, 2019
@chrisirhc
Copy link
Author

Does react-router have official support for server-side handlers?
I'd think this would need to come from fusion.js since fusion's ctx is not something react-router would understand.

That probably means we need a separate plugin then. However, my thought was that it'd be an ask from other users of fusion.js .

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

No branches or pull requests

2 participants