Serve static assets from Firebase Hosting's CDN instead of proxying through Cloud Run - #187
Closed
brianglass wants to merge 1 commit into
Closed
Serve static assets from Firebase Hosting's CDN instead of proxying through Cloud Run#187brianglass wants to merge 1 commit into
brianglass wants to merge 1 commit into
Conversation
…hrough Cloud Run The last real Firebase Hosting deploy of public/ content was ~3.5 years ago -- since then, everything (including static assets) has gone through firebase.json's catch-all rewrite to Cloud Run. Since Firebase Hosting only falls back to that rewrite when no literal file matches under public/, populating public/media with Django's collectstatic output (matching STATIC_URL='media/') makes Firebase serve these files directly from its own CDN on the next `make firebase` deploy, cutting Cloud Run compute for that traffic without any firebase.json changes. Verified via the Firebase Hosting emulator: main.css and htmx.min.js serve with status 200 and byte-identical content from public/media, with no changes to firebase.json's rewrite rule. Excludes servestatic's own compressed sidecar files (.br/.gz/.zstd) from the copy -- those exist for servestatic's on-disk serving scheme, and Firebase Hosting compresses on the fly at its own CDN edge instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hf6j2xXQXywHVh3HAVRxB3
brianglass
force-pushed
the
firebase-static-hosting
branch
from
August 17, 2026 20:47
8521c37 to
34e62bf
Compare
This was referenced Aug 17, 2026
Merged
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
make firebasenow runscollectstaticfirst and mirrors the output intopublic/media(matchingSTATIC_URL='media/'), so Firebase Hosting serves these files directly from its own CDN on the next deploy instead of proxying every static-asset request through Cloud Run.firebase.jsonchanges needed -- Firebase Hosting only falls back to the catch-all Cloud Run rewrite when no literal file matches underpublic/, so a matching file there is served directly. Confirmed this empirically via the Firebase Hosting emulator (see test plan).public/mediais gitignored (build output, regenerated by the Makefile target) and servestatic's own compressed sidecar files (.br/.gz/.zstd) are stripped from the copy, since Firebase compresses on the fly at its CDN edge and never looks for them.servestaticitself stays in the app -- it's still needed for local dev (no Firebase Hosting in front ofdocker compose) and theorthocal-devCloud Run service (not covered byfirebase.json's rewrite, which is hardcoded to theorthocalservice), plus it's a reasonable fallback if amake firebasedeploy is ever forgotten.Test plan
make collectstaticruns cleanly and produces 79 files inpublic/media, with zero leftover.br/.gz/.zstdsidecar files.firebase emulators:start --only hosting) servesmain.cssandhtmx.min.jsfrompublic/mediawith status 200 and content byte-identical to the source files, with nofirebase.jsonchanges.make firebasefor a real deploy (manual, left to Brian).Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
https://claude.ai/code/session_01Hf6j2xXQXywHVh3HAVRxB3