dimanche 26 juin 2016

how does the ember server pass the ember app a url

I have an ember app. With a rails backend. I have the following in my rails routes file.

get '*path' => redirect('/')

This catch all will send everything that is not defined in the route to / where my ember app is located and my application route is executed.

If I have a route in ember that looks like /posts my rails app goes to / and again it executes my application route but not my post route, which makes sense since there was nothing passed to tell it to execute the ember posts route.

So then I went down the long journey of googling until I got to ember-cli-deploy. And while this is incredible, I thought it a bit over kill for what I wanted to do (I might be wrong as maybe I do not really know how hard what I am trying to do is).

So I figured I can set a cookie from rails that would expire in a few seconds. That cookie would have the initial url the user visited before the redirect to /. Before the cookie expires, I can have ember read that cookie and get the url. Then in the ember application route (in the setupController function), before I set session info, ect...; I can this.transitionTo('posts'). (I could not figure out another way to pass the url to the client.)

This is where my question came up. Is there a way I can pass the initial url to ember before getting to the application route. I figure there is a way to do this since, the ember server is doing it. When I run ember server, I am able to navigate to /posts and the application route as well as the posts route are executed.




Aucun commentaire:

Enregistrer un commentaire