vendredi 2 janvier 2015

always ensuring a slash before the hash in ember.js

This may be platform-agnostic but I'll include the server I'm running on.


I'm running into an issue hosting an ember.js site within a directory in IIS.


Let's say I would like to host the site at http://localhost/myapp.


I have a RESTAdapter with the host set to "api" so that requests will go to localhost/myapp/api. If I don't do this, then the RESTAdapter will request from localhost/api.


I have a problem when I navigate to localhost/myapp and follow a link-to to a model. It ends up looking like localhost/myapp#/model which under the hood breaks the api call--it ends up calling localhost/api again (I'm assuming because it truncates everything after the last slash and before the hash). I don't have any problems if I navigate to localhost/myapp/ and take the same actions--the url becomes localhost/myapp/#/model which results in the RESTAdapter call going to /myapp/api/model.


I'm thinking this is going to be a problem when I host the site under a subdirectory (highly likely) as well so I'd like to find out how to solve this problem with as little ad-hoc configuration as possible. Is there a way to always ensure that '/' routes to 'myapp/' or that when a hash is appended it will put '/' in the url if it doesn't already end in it? Or is this something that is going to have to be configured on the server?





Aucun commentaire:

Enregistrer un commentaire