Skip to content

Instantly share code, notes, and snippets.

@gus3inov
Last active May 22, 2018 21:09
Show Gist options
  • Save gus3inov/1a4bc6371974f042f94fffde53f01b08 to your computer and use it in GitHub Desktop.
Save gus3inov/1a4bc6371974f042f94fffde53f01b08 to your computer and use it in GitHub Desktop.
app.use(async (ctx: IContext, next) => {
const context = {};
console.log(ctx.request.url)
const componentHTML = ReactDomServer.renderToString(
<StaticRouter location={ctx.request.url} context={context}>
<Provider store={store}>
<App/>
</Provider>
</StaticRouter>
);
console.log('context ----- ', context.url)
if (context.url) {
ctx.response.redirect(context.url)
}
return ctx.res.end(renderHTML(componentHTML));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment