AppCheck Build Error During Prerender for Angular SSR
See original GitHub issueVersion info
Angular: 13.0.3
Firebase: 9.6.4
AngularFire: 7.2.0
Other (e.g. Ionic/Cordova, Node, browser, operating system): Node 14
How to reproduce these conditions
Steps to set up and reproduce
After setting up AppCheck as such:
import { initializeAppCheck, provideAppCheck, ReCaptchaV3Provider } from '@angular/fire/app-check';
provideAppCheck(() => initializeAppCheck(getApp(), { provider: new ReCaptchaV3Provider(environment.recaptchaSiteKey), isTokenAutoRefreshEnabled: true })),
I am able to serve my application with both yarn server
and yarn dev:ssr
and I’m able to load the site with AppCheck seemingly working. However, when I try to run yarn prerender
, I get the following error:
Unhandled Promise rejection: document is not defined ; Zone: <root> ; Task: Promise.then ; Value: ReferenceError: document is not defined
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
How do I implement firebase app-check in my Angular 12 ...
With this: appCheck.activate('reCAPTCHA secret key');. Hint: click on the app row instead of context menu icon (three dots). It will slide down ...
Read more >Server-side rendering (SSR) with Angular Universal
This guide describes Angular Universal, a technology that renders Angular applications on the server. A normal Angular application executes in the browser, ...
Read more >angular/universal - Gitter
Hi guys any fix for Reference Error document not defined when run npm run dev:ssr ? already added Document to Constructors in every...
Read more >Next.js Pre-rendering and Data Fetching Methods - Pagepro
Learn about SSG, SSR, CSR, and ISR. The most popular pre-rendering and data fetching methods to build fast and SEO-friendly pages in ......
Read more >Integrate Next.js | Firebase Hosting - Google
Before you begin; Initialize Firebase; Serve static content; Pre-render dynamic ... Serve fully dynamic content (SSR); Configure Hosting behavior with ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There is actually an example at https://github.com/angular/angularfire/blob/master/samples/advanced/src/app/app.module.ts#L47-L57
You need to use the admin sdk on server
Here’s my workaround for now…
I created a service:
and then I import the AppCheck module as follows:
This will skip the ReCaptchaV3Provider for server-side rendering and import it only in the browser.