angular - 未更新根 URL www.domain.com 的元标记
问题描述
我正在创建一个部署在 firebase 上的 Angular8 Universal 应用程序。引用了这个网站Angular 通用与 firebase
当我在本地使用 express 服务器运行和服务应用程序时,所有路由都加载了更新的元标记。当我在 firebase 上部署应用程序时,一切正常,但根路径上的元标记没有更新。他们在所有其他路线上都工作得很好。当我打开检查元素时,元标记也会更新。我已经添加了一些配置,用于不缓存 firebase.json 上的 html 文件如何防止 SPA 的 index.html 缓存,并将server.ts 文件中的“缓存”值设置为“无缓存”为
app.get('*', (req, res) => {
res.set('Cache-Control', 'public, max-age=0, s-maxage=0, no-cache');
res.render('index', { req });
});
但没有什么对我有用。请帮忙。
解决方案
这是与 firebase 云功能相关的问题。云功能不会在根路径(www.domain.com)上被调用,因此不会在服务器端更新元标记。我通过在应用程序的根目录中创建文件夹“test”并将所有数据从 dist/browser 文件夹复制到“test”文件夹并将 index.html 文件重命名为其他文件(例如 index2.html)解决了这个问题. 还使用以下行更新了 firebase.json 文件:
....
"hosting": {
"public": "test",
....
因此,每当输入 URL 时,firebase 都会搜索公共文件夹中的 index.html 文件,如果没有 index.html 文件,它将调用我们的云函数。
推荐阅读
- json - 在获取 json 数据和 http 文件时出现异常
- kotlin - 如何重载具有相同参数类型但一个可以为空的函数
- wordpress - 获取 WordPress 插件目录 URI
- android - 如何仅为某些屏幕尺寸和更小尺寸指定文本大小?
- angular - 无法从谷歌表单加载 csv 文件
- android - 如何在 Flutter 中设置带权重的宽度?
- javascript - 在Angular 6中的do while循环中延迟递归HTTP get请求
- php - PHP google联系人api如何检索电话号码
- ios - CALayer 动画宽度
- mysql - JHipster - 在 Hibernate 中使用现有数据库