Title: One call to build the right Firebase app for server rendering · Issue #3843 · angular/angularfire · GitHub
Open Graph Title: One call to build the right Firebase app for server rendering · Issue #3843 · angular/angularfire
X Title: One call to build the right Firebase app for server rendering · Issue #3843 · angular/angularfire
Description: The server-side rendering section of the Authentication guide asks every server-rendered app to write the same 15-line provideFirebaseApp callback: check the platform, read REQUEST_CONTEXT through a cast, fall back to initializeApp when ...
Open Graph Description: The server-side rendering section of the Authentication guide asks every server-rendered app to write the same 15-line provideFirebaseApp callback: check the platform, read REQUEST_CONTEXT through ...
X Description: The server-side rendering section of the Authentication guide asks every server-rendered app to write the same 15-line provideFirebaseApp callback: check the platform, read REQUEST_CONTEXT through ...
Opengraph URL: https://github.com/angular/angularfire/issues/3843
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"One call to build the right Firebase app for server rendering","articleBody":"\nThe [server-side rendering section](https://github.com/angular/angularfire/blob/main/docs/auth.md#server-side-rendering) of the Authentication guide asks every server-rendered app to write the same 15-line `provideFirebaseApp` callback: check the platform, read `REQUEST_CONTEXT` through a cast, fall back to `initializeApp` when there is no token, and pass `releaseOnDeref` to `initializeServerApp`. The guide then lists five details that make it work, and missing any one of them renders the page signed out with no error.\n\nTwo more problems sit in that callback as written:\n\n- A `__session` cookie that Firebase cannot parse makes `initializeServerApp` throw from inside the provider factory, and the request fails with HTTP 500. The cookie only has to be set by something else under that name on the same domain.\n- App Check is never carried to the server. With App Check enforcement on for Firestore, every server render's reads are rejected, and the guide does not say so.\n\n### Proposal\n\nA new function in `@angular/fire/app`, called inside `provideFirebaseApp` once, in the configuration both platforms share:\n\n```ts\nprovideFirebaseApp(() => initializeBrowserOrServerApp(firebaseConfig)),\n```\n\n- In the browser it returns `initializeApp(firebaseConfig)`.\n- On the server it reads `authIdToken` and `appCheckToken` from the request context handed to `handle()` in `server.ts` (an app can pass either explicitly instead) and returns a `FirebaseServerApp` when either is present, or the ordinary app when neither is.\n- The server app is released when the render has been garbage collected, as `releaseOnDeref` does today, so a repeat request from the same visitor reuses it. A `releaseAfterRender` setting opts into a release at render end or a fixed time after it.\n- A token Firebase cannot parse renders the page signed out with one console warning instead of an HTTP 500.\n- In development mode, a request that arrives with no request context is noted once, since that is what a `server.ts` that forgot `handle()`'s second argument looks like.\n\nThe guide's five details would become three: keep exactly one `provideFirebaseApp`, pass `inject(FirebaseApp)` to every product provider, and never call `deleteApp` on the injected app. The guide should also gain a section on relaying the App Check token through the same cookie.\n\nExisting callbacks would keep working. This would not be a breaking change.\n\n","author":{"url":"https://github.com/armando-navarro","@type":"Person","name":"armando-navarro"},"datePublished":"2026-11-10T22:06:32Z","url":"https://github.com/angular/angularfire/issues/3843"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ba29777d-551f-abdf-f1a2-7a90b3ef0fed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D770:A950:30E3ECE:407F6F6:6B035C2E |
| html-safe-nonce | 508cd5d906fc5cb1f8c9b318e4e1a83145a579be5474bf21a82c30cc5cd61c47 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzcwOkE5NTA6MzBFM0VDRTo0MDdGNkY2OjZCMDM1QzJFIiwidmlzaXRvcl9pZCI6IjgyMjYzOTMzMDYxMzgxMDY5MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c3e2f63e544849a917f830c0aee65c602d0eb13a054ac97a1febd5f4546c789b |
| hovercard-subject-tag | issue:6316835097 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angularfire/3843/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ed31690e86d97c4b0dad6140f32d234fbf70967a72e61b2848b069d5b7663cb0/angular/angularfire/issues/3843 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ed31690e86d97c4b0dad6140f32d234fbf70967a72e61b2848b069d5b7663cb0/angular/angularfire/issues/3843 |
| og:image:alt | The server-side rendering section of the Authentication guide asks every server-rendered app to write the same 15-line provideFirebaseApp callback: check the platform, read REQUEST_CONTEXT through ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | armando-navarro |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angularfire git https://github.com/angular/angularfire.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 49453413 |
| octolytics-dimension-repository_nwo | angular/angularfire |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49453413 |
| octolytics-dimension-repository_network_root_nwo | angular/angularfire |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width