Doing the redirect on the front-end is definitely possible, but it will introduce bias to your results. The variation will start with a deficit since it's adding an extra page load to the user experience. So it has to be a lot better to overcome that and win.
One thing you could do is to add your own unique visitor id cookie on the back-end. That way, you have a way to identify someone before the app loads and can split traffic on the back-end, even for anonymous users.