【问题标题】:How to serve Angular deeplinks from a Cloud CDN storage bucket如何从 Cloud CDN 存储桶提供 Angular 深层链接
【发布时间】:2017-03-03 16:43:56
【问题描述】:

我正在使用 Google Cloud Storage 存储桶通过 Google Cloud CDN 为我的 Angular 网站提供服务。 它在我尝试访问 mysite.com/index.html 时有效,但我网站上的一些操作正在执行 url 重写。

我最终可以拥有像mysite.com/myaction 这样的网址

当用户通过 F5 刷新或导航返回时,会出现一条错误消息,并且不会提供内容。

负载均衡器、桶中或云cdn中没有这样的选项。

如何使用此配置提供此类深层链接?

【问题讨论】:

    标签: google-cloud-platform


    【解决方案1】:

    只要 'myaction' 不是文件,Cloud CDN 就不会在 Cloud Storage 存储桶中找到它,并会抛出错误('No such keys'),这意味着它没有找到任何名为 'myaction' 的对象.

    此错误类似于 404。 您的 Angular 网站是一个单页应用程序,您希望始终提供 index.html,因此您可以使用 gcloud 命令:

    gsutil web set -m index.html gs://name_of_your_bucket
    gsutil web set -e index.html gs://name_of_your_bucket
    

    这会将 index.html 设置为在 url 中未指定文件时的默认页面,或者在 404 错误的情况下登录页面。

    【讨论】:

      猜你喜欢
      • 2019-01-23
      • 1970-01-01
      • 2019-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-25
      • 2020-04-13
      • 1970-01-01
      相关资源
      最近更新 更多