Ember CLI /浏览器刷新/生产/ 404 [英] Ember CLI / browser refresh / production / 404

查看:93
本文介绍了Ember CLI /浏览器刷新/生产/ 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ember CLI 0.1.15开发了我的webapp,具有emberjs。 1.8.1



我用这个命令构建了应用程序:ember build - 环境生产,然后我在我的dist文件夹下生成的文件中做了一个WAR项目,然后我将WAR放在我的tomcat的webapps文件夹上。



所以,当我打开应用程序: http:// mytomcat / myapp / ...它没关系,我看到我的登录屏幕,我登录,并在我的应用程序中浏览,一切都很好。我也可以做后退/前进按钮,并且ember处理转换。



但是当我点击浏览器上的刷新按钮 - 浏览器的地址栏目前正在 http:// mytomcat / myapp / inventory / 显示 - 我有404个回复,从tomcat。



然后我知道为什么发生这种情况:刷新按钮向Tomcat发送请求,路径/ myapp / myinventory / ...当然路径/ myinventory不存在于服务器上。我们在浏览器上看到的所有路线 - 基本网址除外, http:// mytomcat / myapp / - 在客户端生成。



所以,我的问题是:处理这种情况的方法是什么?我需要刷新按钮才能正常工作。任何方式用于截取刷新按钮点击事件的方式?



我猜这个问题与此有关: https://github.com/stefanpenner/ember-app-kit/issues/486 ,但它没有我需要的答案。

提前感谢
Raka



---更新---



可能相关: http: //eviltrout.com/2014/04/10/the-refresh-test.html

解决方案


  1. config / environment.js 文件内,有一个名为 locationType 的属性。将其值设置为哈希


  2. / dist 文件夹是耗时且烦人的。相反,您可以在 .ember-cli 中指定您正在尝试的webapps中的位置的输出路径属性将文件移动到。另一个选项是将此选项指定为 ember服务器 ember build



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. 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

这篇关于Ember CLI /浏览器刷新/生产/ 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆