Title: fix(app-check)!: skip App Check during server rendering by default by armando-navarro · Pull Request #3773 · angular/angularfire · GitHub
Open Graph Title: fix(app-check)!: skip App Check during server rendering by default by armando-navarro · Pull Request #3773 · angular/angularfire
X Title: fix(app-check)!: skip App Check during server rendering by default by armando-navarro · Pull Request #3773 · angular/angularfire
Description: Fixes #3488 Fixes #3128 Refs #3089 Following docs/app-check.md in a server-rendered app fails the build with ReferenceError: document is not defined. provideAppCheck runs the app's setup function during server rendering, and the reCAPTCHA providers need a browser. This PR skips App Check during server rendering by default, with an opt-in for apps that run it there on purpose. ImportantThis is a breaking change, so it needs to merge before 21.0.0 is tagged. Breaking change During server rendering, AngularFire no longer calls the function passed to provideAppCheck, and inject(AppCheck) returns null there. The browser is unchanged. Apps that run App Check on the server on purpose, with a server-capable provider such as a CustomProvider backed by the Admin SDK, keep the old behavior with one line in their server config: { provide: APP_CHECK_ON_SERVER, useValue: true } Firebase's documented route for App Check in server renders passes a client-generated token to initializeServerApp as appCheckToken. It needs no App Check instance on the server, so this change does not affect it. Changes appCheckInstanceFactory returns early during server rendering unless APP_CHECK_ON_SERVER is true, and in development mode it warns once that it skipped App Check. APP_CHECK_ON_SERVER is a new export from @angular/fire/app-check, false by default. defaultAppCheckInstanceFactory drops skipped entries before choosing the default instance. ɵgetDefaultInstanceOf reads .app on every entry, so an app calling provideAppCheck twice would otherwise crash on the server. New specs in src/app-check/app-check.spec.ts cover the server default, two provideAppCheck calls on the server, the opt-in, and the browser. The docs change follows in a separate PR. Verification On an Angular 21.2 app rendered at build time, using the setup from docs/app-check.md: 21.0.0-rc.1: ng build fails with ReferenceError: document is not defined. This branch: the build succeeds, and AppCheck is null on the server. This branch with APP_CHECK_ON_SERVER and the reCAPTCHA provider: the original error returns, so the opt-in does run App Check on the server. This branch with APP_CHECK_ON_SERVER and a CustomProvider on the server: the build succeeds with a real AppCheck on the server. The warning prints in a development build and not in a production build. npm run test:chrome-headless: 111 passed, 48 skipped. npm run test:node: 331 specs, 0 failures. Each new spec fails when the code it covers is disabled: the server skip, the filter, or the opt-in.
Open Graph Description: Fixes #3488 Fixes #3128 Refs #3089 Following docs/app-check.md in a server-rendered app fails the build with ReferenceError: document is not defined. provideAppCheck runs the app's setup functi...
X Description: Fixes #3488 Fixes #3128 Refs #3089 Following docs/app-check.md in a server-rendered app fails the build with ReferenceError: document is not defined. provideAppCheck runs the app's setup fu...
Opengraph URL: https://github.com/angular/angularfire/pull/3773
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
| 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:1a0f3882-ad16-596a-dce3-7446d3e750b8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A680:31B648:20889B:2B8FB2:6B03C743 |
| html-safe-nonce | 08ed24e96035ba8184c2ddd0cbf96c7914ef21d600143e9b48a8fd95105c3ca3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjgwOjMxQjY0ODoyMDg4OUI6MkI4RkIyOjZCMDNDNzQzIiwidmlzaXRvcl9pZCI6IjY1NjIyODU5MDIwNjI5Mjk3MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 53a11cf63370e3b48948390da77563938513883caa853b47bcc2f969a14047e0 |
| hovercard-subject-tag | pull_request:4642958213 |
| 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/3773/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 | Fixes #3488 Fixes #3128 Refs #3089 Following docs/app-check.md in a server-rendered app fails the build with ReferenceError: document is not defined. provideAppCheck runs the app's setup functi... |
| 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 full-width |
| 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