Skip to content

Redirect all requests to a Function or Cloud Run service without any public directory #3349

@steren

Description

@steren

I originally asked this question on Stackoverflow but I was advised by @mbleigh to open a Feature Request here.

I am using Firebase Hosting for many websites. Some websites have static files that I want to serve from Firebase Hosting static file serving, however, some others only have dynamic content for which I want to leverage Firebase's custom domain and caching.

It seems that the public attribute is required in firebase.json . This requires me to deploy a public folder with a dummy file in it.

It would be great to allow deploying to Firebase Hosting without any public directory,but with at least one function or run redirect.

The following gives me this error: 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"
                    }
                }
            ]
        }
    ]
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions