【问题标题】:Firebase avoid CORS being removed after redirectFirebase 避免在重定向后删除 CORS
【发布时间】:2017-08-04 21:57:07
【问题描述】:

我有一个启用了 CORS 的 Firebase 函数,当我从我的网站使用它的 firebase 域从 AJAX 调用它时,我已经在 Firebase 托管中设置了一个自定义域,并在尝试后重定向到函数域由于在重定向中删除了 CORS 标头,我遇到了一些问题,但是如何在作为重定向的 firebase 托管域中实现 CORS 标头?

【问题讨论】:

    标签: firebase cors


    【解决方案1】:

    解决方案是使用重写而不是重定向,这里是文档:

    https://firebase.google.com/docs/hosting/functions#directing_hosting_requests_to_your_function

    还有一个 firebase.json 示例:

    {
      "hosting": {
    "public": "public",
    
    // Add the following rewrites section *within* "hosting"
    "rewrites": [ {
      "source": "/bigben", "function": "bigben"
    } ]
      }
     }
    

    【讨论】:

      猜你喜欢
      • 2020-08-12
      • 2021-01-05
      • 2020-11-02
      • 2011-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-24
      • 1970-01-01
      相关资源
      最近更新 更多