AngularJS HTML5 模式 [英] AngularJS HTML5Mode

查看:27
本文介绍了AngularJS HTML5 模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 angular 应用程序中使用 HTML5 模式来关闭 hashbangs,这是因为我将为我的用户提供 URL,例如:

I am using HTML5 mode in my angular app to turn off hashbangs and that is because I am going to be providing URLs for my users like:

http://myapp.com/nicklewis

而不是:

http://myapp.com#/nicklewis

后者有效,但不适用于虚 URL.

The latter works but it isn't ideal for vanity URLs.

我还没有编写自己的 NodeJS 应用来解决这个问题,Firebase 中是否有任何我可以使用的东西?

So short of writing my own NodeJS app to resolve this issue, is there anything in Firebase I could make use of or not?

推荐答案

Firebase 最近有一个包含此功能的更新.您可以在 firebase.json 中像这样使用它:

Firebase just had a recent update that included this functionality. You can use it like so in your firebase.json:

"rewrites": [ {
    "source": "**",
    "destination": "/index.html"
} ]

这是他们的文档中使用的代码示例,它将把任何找不到的目录或文件发送回 index.html.

This is the code sample used in their docs and will send any directory or file that is not found back to index.html.

请务必注意,您需要将 Firebase 部署工具更新到 1.1.0 版或更高使其工作:

It's important to note that you will need to update your firebase deployment tools to version 1.1.0 or higher for this to work:

$ npm update -g firebase-tools

根据您的权限,您可能需要使用sudo".

You may need to use 'sudo' with this depending on your permissions.

您可以在此处阅读文档:https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html

You can read the documentation here: https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html

您可以在此处阅读有关更新 Firebase 工具的信息:https://www.firebase.com/docs/hosting/guide/command-line-tool.html

You can read about updating firebase tools here: https://www.firebase.com/docs/hosting/guide/command-line-tool.html

这篇关于AngularJS HTML5 模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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