【问题标题】:How to Redirect all requests to a Function or Cloud Run service without any public directory?如何在没有任何公共目录的情况下将所有请求重定向到 Function 或 Cloud Run 服务?
【发布时间】:2021-07-30 17:51:16
【问题描述】:

我正在为许多网站使用 Firebase 托管。有些网站有我想通过 Firebase 托管静态文件服务提供的静态文件,但是,其他一些网站只有我想利用 Firebase 的自定义域和缓存的动态内容。

firebase.json 中似乎需要 public 属性。这需要我部署一个包含虚拟文件的公用文件夹。

有没有办法在没有任何public 目录的情况下部署到 Firebase 托管?

以下给了我这个错误:Error: Must supply a public directory using "public" in each "hosting" config.

{
    "hosting": [
        {
            "target": "index",
            "public": "static",
            "rewrites": [
                {
                    "source": "**",
                    "destination": "/index.html"
                }
            ]
        },
        {
            "target": "api",
            "rewrites": [
                {
                    "source": "**",
                    "run": {
                        "serviceId": "api",
                        "region": "us-central1"
                    }
                }
            ]
        }
    ]
}

【问题讨论】:

标签: firebase-hosting google-cloud-run


【解决方案1】:

documentation 可以看出,public 文件夹是必需的,并且它必须存在。否则部署最终会出错。最好避免这种情况。

我在上一个项目中也必须这样做,其中包含虚拟文件夹和 index.html 文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-21
    • 2011-09-13
    相关资源
    最近更新 更多