Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember CLI / browser refresh / production / 404

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

like image 268
Cokorda Raka Avatar asked Feb 19 '15 22:02

Cokorda Raka


1 Answers

  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

like image 156
Kalman Avatar answered Nov 02 '22 14:11

Kalman