根URL www.domain.com的元标记未更新

时间:2019-12-03 09:22:59

标签: angular google-cloud-functions angular8 firebase-hosting angular-universal

我正在创建一个部署在firebase上的Angular8 Universal应用程序。已推荐该网站Angular universal with firebase

当我在本地运行Express Server并将其提供服务时,所有路由都将加载更新的meta标签。当我在Firebase上部署应用程序时,一切正常,但根路径上的meta标签未更新。它们在所有其他路线上都可以正常工作。当我打开检查元素时,元标记也会更新。我添加了一些配置,以免在firebase.json How to prevent caching for the index.html of an SPA上缓存html文件,并且还在server.ts文件中将“ cache”值设置为“ No-cache”,

app.get('*', (req, res) => {
  res.set('Cache-Control', 'public, max-age=0, s-maxage=0, no-cache');
  res.render('index', { req });
});

但是对我没有任何帮助。请帮忙。

1 个答案:

答案 0 :(得分:2)

这是与Firebase云功能有关的问题。不会在根路径(www.domain.com)上调用云功能,因此不会在服务器端更新元标记。 我通过在应用程序的根目录中创建文件夹“ test”并将所有数据从dist / browser文件夹复制到“ test”文件夹并将index.html文件重命名为其他文件(例如index2.html)来解决了此问题。还使用以下行更新了firebase.json文件:

....
"hosting": {
    "public": "test",
    ....

因此,只要输入URL,firebase就会在公用文件夹中搜索index.html文件,如果不存在index.html文件,它将调用我们的云函数。