Firebase 静态网站托管停止工作“找不到网站”

问题描述 投票:0回答:1
  1. 需要重写我网站的某些页面的规则。所以我想简单地包括我的重写,如下所示。

这是我的 firebase.json

{
  "hosting": {
    "site": "mysite_id",
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/report/doc_view/**",
        "destination": "https://mynewsite.com/report/doc_view/**",
        "type": "302"
      }
    ],
    "headers": [
      {
        "source": "*",
        "headers": [
          {
            "key": "Access-Control-Allow-Origin",
            "value": "*"
          }
        ]
      },
      {
        "source": "**",
        "headers": [
          {
            "key": "Access-Control-Allow-Origin",
            "value": "*"
          }
        ]
      }
    ]
  }
}

在 24 小时后我的上次部署状态中,我的网站显示如下。

我的网站需要更新什么并准备好? 请告诉我为什么我从 Firebase 收到“网站未找到”错误的原因。

  1. 某些后端服务(如 /cgi-bin/login.cgi)需要从 Firebase 托管的网站重定向到 mynewsite.com。
{
  "hosting": {
    "site": "mysite_id",
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/report/doc_view/**",
        "destination": "https://mynewsite.com/report/doc_view/**",
        "type": "302"
      }
    ],
    "redirects": [
      {
        "source": "/cgi-bin/login.cgi",
        "destination": "https://mynewsite.com/cgi-bin/login.cgi",
        "type": 301
      }
    ]
    "headers": [{
      "source": "*",
      "headers": [{
        "key": "Access-Control-Allow-Origin",
        "value": "*"
      }]
    }, {
      "source": "**",
      "headers": [{
        "key": "Access-Control-Allow-Origin",
        "value": "*"
      }]
    }]
  }
}

此类重写可能会导致上述站点未找到错误。我在生产部署中遇到了这一点。请帮助我。

firebase url-rewriting firebase-hosting
1个回答
0
投票

Firebase Hosting 中的重写需要指向同一网站上的路径。来自配置重写的文档:

(推荐)或正则表达式
一种 URL 模式,如果与初始请求 URL 匹配,则会触发 Hosting 应用重写

使用 source 指定 glob(推荐)。
使用 regex 指定 RE2 正则表达式。

目的地
必须存在的本地文件

此 URL 可以是相对路径或绝对路径。

因此目标必须是本地文件,它不能是您尝试使用的 HTTP URL。

如果您想将用户发送到该 HTTP URL,您必须将其作为

redirect

 而不是 
rewrite
 规则放入。

© www.soinside.com 2019 - 2024. All rights reserved.