{"action":"created","issue":{"url":"https://api.github.com/repos/denvned/isomorphic-relay-router/issues/26","repository_url":"https://api.github.com/repos/denvned/isomorphic-relay-router","labels_url":"https://api.github.com/repos/denvned/isomorphic-relay-router/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/denvned/isomorphic-relay-router/issues/26/comments","events_url":"https://api.github.com/repos/denvned/isomorphic-relay-router/issues/26/events","html_url":"https://github.com/denvned/isomorphic-relay-router/issues/26","id":151340774,"number":26,"title":"Server side doesn't receive correct location after match()","user":{"login":"psalz","id":791348,"avatar_url":"https://avatars.githubusercontent.com/u/791348?v=3","gravatar_id":"","url":"https://api.github.com/users/psalz","html_url":"https://github.com/psalz","followers_url":"https://api.github.com/users/psalz/followers","following_url":"https://api.github.com/users/psalz/following{/other_user}","gists_url":"https://api.github.com/users/psalz/gists{/gist_id}","starred_url":"https://api.github.com/users/psalz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psalz/subscriptions","organizations_url":"https://api.github.com/users/psalz/orgs","repos_url":"https://api.github.com/users/psalz/repos","events_url":"https://api.github.com/users/psalz/events{/privacy}","received_events_url":"https://api.github.com/users/psalz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-27T09:32:38Z","updated_at":"2016-04-27T13:03:48Z","closed_at":"2016-04-27T10:52:55Z","body":"The new `applyRouterMiddleware` approach to things causes an issue where the server side code doesn't receive the correct routing information after a call to `match`. This is actually happening in the todo-example, where requesting anything other than `/` (e.g. `/completed`) will cause React to complain about invalid checksums. When disabling client-side Javascript, you will see that only the `/` route is rendered, no matter the actually requested route.\r\n\r\nI'm anything but involved in the react-router codebase, but I _think_ I have found the root cause and also have a potential solution, although I'm not sure if this should be resolved in userland (here) or in react-router itself.\r\n\r\nPreviously, when rendering a `RouterContext`, the `location` prop was directly provided by the `renderProps` returned from `match`. With the new approach, this is no longer the case: The `Router` component [uses its state](https://github.com/reactjs/react-router/blob/02221fed010fdc2b1e4847c6595cdf469eaea91a/modules/Router.js#L144) for the location. This state variable is changed in a history listener, [here](https://github.com/reactjs/react-router/blob/02221fed010fdc2b1e4847c6595cdf469eaea91a/modules/Router.js#L77). Note that this listener [immediately fires once](https://github.com/mjackson/history/blob/73195152c808a996bd0d239e0e54bfbb8d72f10f/modules/createHistory.js#L71) upon registering, so this is not an async issue. The problem lies a couple of lines below: As this newly created history doesn't yet have a `location`, a call to `getCurrentLocation` is made. Assuming a `MemoryHistory`, which is the default, the call ends [here](https://github.com/mjackson/history/blob/73195152c808a996bd0d239e0e54bfbb8d72f10f/modules/createMemoryHistory.js#L76), where `entries[current]` simply equals `/` at this point (see line 36). This never gets changed, so the `Router` state is never updated, and all child components receive `/` as the location.\r\n\r\nI'm wondering if the `TransitionManager` should update the history state upon a successful `match`. \r\n\r\nAnyway, in the meantime, simply adding\r\n\r\n`renderProps.router.replace(renderProps.location)`\r\n\r\nto `prepareData` solves the issue for me.\r\n\r\nNote that applying this fix may still cause invalid checksums at times, but this is due to another issue (https://github.com/facebook/react/issues/6451).\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/denvned/isomorphic-relay-router/issues/comments/215074965","html_url":"https://github.com/denvned/isomorphic-relay-router/issues/26#issuecomment-215074965","issue_url":"https://api.github.com/repos/denvned/isomorphic-relay-router/issues/26","id":215074965,"user":{"login":"mattecapu","id":5738009,"avatar_url":"https://avatars.githubusercontent.com/u/5738009?v=3","gravatar_id":"","url":"https://api.github.com/users/mattecapu","html_url":"https://github.com/mattecapu","followers_url":"https://api.github.com/users/mattecapu/followers","following_url":"https://api.github.com/users/mattecapu/following{/other_user}","gists_url":"https://api.github.com/users/mattecapu/gists{/gist_id}","starred_url":"https://api.github.com/users/mattecapu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattecapu/subscriptions","organizations_url":"https://api.github.com/users/mattecapu/orgs","repos_url":"https://api.github.com/users/mattecapu/repos","events_url":"https://api.github.com/users/mattecapu/events{/privacy}","received_events_url":"https://api.github.com/users/mattecapu/received_events","type":"User","site_admin":false},"created_at":"2016-04-27T13:03:47Z","updated_at":"2016-04-27T13:03:47Z","body":"Great job @psalz, I was experiencing the same issue but I wasn't able to find the cause.\r\nAnd as always thanks to @denvned for his dedication to the project :smile:"}}