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

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

问题描述

我使用 Ember CLI 0.1.15 和 emberjs 开发了我的 web 应用程序.1.8.1

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

我使用以下命令构建了应用程序: ember build --environment production ,然后我从我项目的 dist 文件夹下生成的文件中创建了一个 WAR,然后我将 WAR 放到了我的 tomcat 的 webapps 文件夹中.

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.

所以,当我打开应用程序时:http://mytomcat/myapp/ ...一切顺利,我看到了我的登录屏幕,我登录并在我的应用程序中导航,一切都很好.我也可以做后退/前进按钮,而且 ember 可以很好地处理过渡.

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.

但是当我点击浏览器上的刷新按钮时——浏览器的地址栏显示 http://mytomcat/myapp/inventory/ 在那一刻——我收到了 404 回复,来自 tomcat.

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.

然后我想出了为什么会这样:刷新按钮向 tomcat 发送了路径/myapp/myinventory/的请求……当然路径/myinventory 在服务器上不存在.我们在浏览器上看到的所有路由——除了基本 url,http://mytomcat/myapp/——在客户端生成.

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.

所以,我的问题是:处理这种情况的正确方法(在 ember 中)是什么?我需要刷新按钮才能正常工作.ember 有什么办法拦截刷新按钮的点击事件吗?

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?

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

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.

提前致谢,拉卡

--- 更新---

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

推荐答案

  1. config/environment.js 文件中,有一个名为locationType 的属性.将其值设置为 hash

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

/dist 文件夹手动移动文件既费时又烦人.相反,您可以在您的 .ember-cli 中指定一个 output-path 属性,并使用您尝试将文件移动到的 web 应用程序中的位置.另一种选择是将此选项指定为 ember serverember build

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天全站免登陆