8
votes

I developed my webapp using Ember CLI 0.1.15, with emberjs. 1.8.1

I built the app with this command: ember build --environment production , and then I made a WAR out of the files produced under the dist folder of my project, and then I drop the WAR on my tomcat's webapps folder.

So, when I open the app: http://mytomcat/myapp/ ... it went fine, I saw my login screen, I logged in, and navigate around in my app, everythings fine. I could also do the back/forward button, and ember handles the transition well.

But when I click the refresh button on my browser -- the address bar of the browser was showing http://mytomcat/myapp/inventory/ at that moment -- I got 404 reply, from the tomcat.

Then I figured out why it happened: the refresh button sends a request to the tomcat for the path /myapp/myinventory/ ... of course the path /myinventory does not exist on the server. All those routes we see on the browser -- except for the base url, http://mytomcat/myapp/ -- are generated on the client-side.

So, my question is: what's the right way (in ember) to deal with this situation? I need the refresh button to just works. Any way for ember to intercept the refresh button clicked event?

I guess this issues is related to this: https://github.com/stefanpenner/ember-app-kit/issues/486 , but it does not have the answer I need.

Thanks in advance, Raka

--- UPDATE ---

Probably relevant: http://eviltrout.com/2014/04/10/the-refresh-test.html

1
Thanks! it works. How to accept it as answer? By the way.... now another issue (separate one), apparently when you hit the refresh button, the browser reloads the entire site (with all the scripts), resetting everything, including the "loggedInUser" I put in the application controller.... Is it the browser thing? Or ember thing? How to stop any of them / both to just stop doing that.... Or is pressing refresh really a crime?Cokorda Raka

1 Answers

9
votes
  1. Inside config/environment.js file, there is a property called locationType. Set its value to hash

  2. Manually moving files from your /dist folder is time consuming and annoying. Instead, you can specify an output-path property in your .ember-cli with the location inside webapps you are trying to move the files to. Another option is to specify this option to ember server or ember build