I am probably not the first who asks this question, but I still cannot find a solution.
An Ember application is based on:
- Ember CLI 0.2.0-beta.1
- Ember 1.10.0
- Ember Simple Auth 0.8.0-beta.3
The application is deployed on a Tomcat server. When a user traverses through application pages, browser URL changes itself based on defined application routes.
If at some moment the application is in a route, let’s say, http://my-domain/my-app/one/two/three and a user does browser refresh (F5), then the Tomcat (and not Ember application itself) tries to find the path one/two/three in the deployed web application and obviously a user gets an error.
I found some advises to set the locationType property to hash in Ember CLI config (it was auto by my side). But the problem does not get resolved with it, and in addition the Ember Simple Auth stops to work.
Has anyone had a positive experience with browser refresh for an Ember CLI application?
This isn’t an Ember problem at all. Tomcat isn’t serving your my-app/index.html in /my-app/one/two/three and you are reaching in a server 404 error.
I don’t know much about Tomcat except by using it once or twice, but you could probably find some way to use some sort of URL rewriting to point all URLs (except static files) to my-app/index.html.
I found some advises to set the locationType property to hash in Ember CLI config (it was auto by my side). But the problem does not get resolved with it, and in addition the Ember Simple Auth stops to work.
I’ve had the same problem as you and this solved it for me. I’m using Simple Auth as well, so Ember doesn’t seem to be the problem.
One of the problems for newcomers with Ember.js is that error messages during transitions, by default, sort of get swallowed. (By the time an error is logged, it’s not the original error.) And of course, in a new environment making sense of errors is something that takes a while to learn. But I thought I’d share something from “the other side”, just for amusement.
I tried to log into iTunes Connect (Apple’s site for those who publish software on their App Stores) this morning, and, as it occasionally does, the page was totally blank. Unusually, it won’t display after a refresh. So what the heck, I decide to open the dev console and take a look. Sure enough, a Javascript error! And, the error message, to me at least, is an absolute classic:
@adr1 I got around this issue (using a CakePHP backend) by creating a custom DispatcherFilter that checks whether the request is XHR and wasn’t for the main index. If both tests are negative, the request is changed to serve the main index. Importantly, I’m not redirecting the request, just changing what will serve it. Ember then “sees” what the actual request is and loads the appropriate route.
It’s been awhile (~10 years!) since i poked around in Tomcat’s xml configs but I’m pretty sure you could do something similar.
@sribe Nice! Those hex sequences look like an md5 hash; probably a version string