Build Firebase Hosting configurations with rewrites, redirects, custom headers, and Cloud Run integration.
Build Firebase Hosting configurations with rewrites, redirects, custom headers, Cloud Run integration, and caching rules.
Required Fields
hosting.sitehosting.publichosting.rewritesOutput will appear here...Build a Firebase Hosting configuration covering rewrites, redirects, custom headers, and Cloud Run/Functions integration. Rewrites are evaluated in the order they appear and the first matching glob wins, so a catch-all `**` rewrite to /index.html must come last or it swallows every more-specific rule declared after it, a classic single-page-app misconfiguration. cleanUrls strips .html from served paths and trailingSlash controls whether Hosting normalizes a trailing slash away or adds one, both affect canonical URLs and, if changed after launch, can quietly create duplicate-content issues for anything that was indexed under the old URL shape.
A team deploys a new /api/** rewrite pointing at a freshly-launched Cloud Run backend, but every request to it comes back with the SPA's HTML shell instead of JSON, and the Cloud Run logs show zero incoming traffic at all despite the frontend clearly making the calls. The rewrites array has the SPA's catch-all `**` to /index.html declared before the new /api/** entry, added months earlier and never revisited. They use the builder to reorder the array with /api/** and /auth/** first and the catch-all strictly last, redeploy, and traffic starts reaching the Cloud Run service on the very next request.
Rewrite array order is load-bearing — always put narrower path patterns before broader ones, and the SPA fallback `**` rewrite absolute last, or specific routes silently stop working after someone adds a new broad rule above them.
Cache-Control headers on hashed asset filenames (content-hash in the name) can safely use max-age=31536000, immutable since a content change produces a new filename; the same header on unhashed files like index.html causes stale deploys to persist in browsers for up to a year.
i18n content negotiation via the root config only affects paths under that root; requests outside it fall back to default content, a mismatch here is a common cause of one locale silently not localizing while others work fine.
The builder requires hosting.site, hosting.public, and hosting.rewrites to resolve before treating the JSON as deployable, the minimum Firebase needs to know which site, which local directory maps to it, and how requests route, everything else (headers, redirects, i18n) layers on top as optional but structurally-validated JSON.
Was this tool helpful?
Disclaimer: This tool runs entirely in your browser. No data is sent to our servers. Always verify outputs before using them in production. AWS, Azure, and GCP are trademarks of their respective owners.