Title: docs(auth): rewrite the server-side rendering section by armando-navarro · Pull Request #3740 · angular/angularfire · GitHub
Open Graph Title: docs(auth): rewrite the server-side rendering section by armando-navarro · Pull Request #3740 · angular/angularfire
X Title: docs(auth): rewrite the server-side rendering section by armando-navarro · Pull Request #3740 · angular/angularfire
Description: Checklist Issue number for this PR: #3585 Docs included?: yes (documentation-only change) Test units included?: no (documentation-only change) In a clean directory, yarn install, yarn test run successfully?: not applicable, no source changed Description Rewrites the Server-side Rendering section of docs/auth.md, which documented a setup that does not work. Defects in the old section: It read the ID token through inject(REQUEST) and request.headers.authorization, but REQUEST is a standard Request, so headers come from headers.get(...). initializeServeApp in the import list is a typo. provideAuth is missing its closing paren. REQUEST and FirebaseApp are used without being imported. #3585 is a reader hitting this one. A bare ... placeholder inside the providers array does not parse. The new section documents the path that works, as four steps, each with the reason it is needed: RenderMode.Server on any route that has to render as the signed-in user. ng new --ssr scaffolds every route as RenderMode.Prerender, and Angular supplies REQUEST and REQUEST_CONTEXT only on server-rendered routes. A __session cookie kept in sync with the ID token, with secure and sameSite set, and why that cookie name matters behind Firebase Hosting. Replacing the generated handler in server.ts rather than adding a second one. Passing inject(FirebaseApp) to every provider, not only provideAuth, because ng add writes them with no argument. Leaving out any one of the four still renders the page, signed out, with no error anywhere. That silence is what made the old section expensive to debug, so each step states what breaks without it. The section was written against a new ng new --ssr Angular 21 app set up with ng add @angular/fire@next, where a signed-in user's first request to a freshly started server returns signed-in HTML. One import is deliberately inconsistent, and the section explains it: beforeAuthStateChanged comes from firebase/auth, not @angular/fire/auth. Our wrapper keeps the app marked busy until that callback first runs, and it only runs on a sign-in or sign-out. So importing it from AngularFire makes ng build hang during route extraction and fail with a timeout. I am filing that bug separately. Also corrects the emulator example further down the same file, which used the no-argument getAuth that the new section warns against. Documentation only, no source or API changes. Fixes #3585
Open Graph Description: Checklist Issue number for this PR: #3585 Docs included?: yes (documentation-only change) Test units included?: no (documentation-only change) In a clean directory, yarn install, yarn test run suc...
X Description: Checklist Issue number for this PR: #3585 Docs included?: yes (documentation-only change) Test units included?: no (documentation-only change) In a clean directory, yarn install, yarn test run suc...
Opengraph URL: https://github.com/angular/angularfire/pull/3740
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e4c3b683-00bc-58de-87a5-98bfbe404778 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | EB6C:32A57E:70EC65:8F3312:6B03697B |
| html-safe-nonce | ccda3cd19abcf6c46f843c6a9a5c65158a417ea968d37c245cf0861e5e5c35c4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjZDOjMyQTU3RTo3MEVDNjU6OEYzMzEyOjZCMDM2OTdCIiwidmlzaXRvcl9pZCI6IjQ1OTMyMjU0MDg5NzA5NzU2MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ffb70729dbd4bd3019341cfa4d18a6af46062837b83109067837e4f8fc5fb6db |
| hovercard-subject-tag | pull_request:4249441436 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/angular/angularfire/pull/3740/files |
| twitter:image | https://avatars.githubusercontent.com/u/13904589?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/13904589?s=400&v=4 |
| og:image:alt | Checklist Issue number for this PR: #3585 Docs included?: yes (documentation-only change) Test units included?: no (documentation-only change) In a clean directory, yarn install, yarn test run suc... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 | true |
| 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 |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width