当我刷新我的网站,我收到了404这是Angular2和火力点 [英] When I refresh my website I get a 404. This is with Angular2 and firebase

查看:817
本文介绍了当我刷新我的网站,我收到了404这是Angular2和火力点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我刷新我的网站,我收到了404这是Angular2,打字稿及火力点。

我已经部署了我的Angular2应用firebaseapp。

路线似乎改变正常,但当我刷新浏览器重定向我404页。

当我刷新当地不会发生这种情况。

我缺少任何路由设置或设置火力地堡?

这是我的firebase.json文件:

  {
   火力点:测试,
   公:SRC
   忽​​视: [
     firebase.json
     ** /。*,
     ** / node_modules / **
   ]
 }


解决方案

有关火力地堡托管在重定向的文档,并重写是在这里:的 https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html

从那里:


  

当你想显示多个URL相同的内容使用重写。重写与模式匹配中特别有用,因为你可以接受的是,模式匹配的网址,让客户端code决定要显示的内容。


你很可能会寻找一个页面上的第一个重写示例:

 重写:[{
  资源: **,
  目标:/index.htm」明明
}]

这是Web服务器服务 /index.html 任何传入的请求,无论路径是什么样的指令。

When I refresh my website I get a 404. This is with Angular2, typescript and firebase.

I've deployed to firebaseapp with my Angular2 app.

Routes seem to change fine but when I refresh the browser it redirects me to 404 page.

When I refresh locally this doesn't happen.

Am I missing any route settings or Firebase settings?

This is my firebase.json file:

 {
   "firebase": "test",
   "public": "src",
   "ignore": [
     "firebase.json",
     "**/.*",
     "**/node_modules/**"
   ]
 }

解决方案

For Firebase Hosting the documentation on redirects and rewrites is here: https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html

From there:

Use a rewrite when you want to show the same content for multiple URLs. Rewrites are particularly useful with pattern matching, as you can accept any URL that matches the pattern and let the client-side code decide what to display.

You're likely looking for the first rewrite sample on that page:

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

This is an instruction for the web server to serve /index.html for any incoming request, no matter what the path is.

这篇关于当我刷新我的网站,我收到了404这是Angular2和火力点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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