How to render a specific page on the server?
iKonrad opened this issue · comments
Hi. Great boilerplate!
I'm almost done with my authentication system, but there's one thing that's bugging me a bit.
I'm in the process of implementing the account activation - so when someone clicks on the activation link from the e-mail, server validates the token and displays appropriate message.
Because the routing is set up so React has the final word on rendering the template, I'm left with letting react-router do the redirect and sending an ajax request back to the server.
That feels a bit weird to send an api request to the server from the VM, doesn't it?
So the question is, how can I handle the HTTP request before the template gets rendered by VM?
I could use a middleware, but I think it's not the right tool for handling regular HTTP requests.
Hi,
the short answer is use echo's routing for this.
Take a look at this. that means that react VM will be used only for undefined urls. So, define url and handle it at server directly.
That feels a bit weird to send an api request to the server from the VM, doesn't it?
Nope, it's totally ok. But for more performance, you are able to use method above.
Thanks, I managed to get that done by moving the react.go to a separate package, and then within my route handler, I'm calling React.Handle(c) to render the view :)