Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Using with Angular 17 SSR -> document is not defined on initializeAppCheck

Đang mở
#3,488 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
angular, firebase, typescript
Lĩnh vực
frontend, security

Hướng nghiên cứu

Bắt đầu bằng cách đọc docs/app-check.md và lần theo lệnh gọi initializeAppCheck được hiển thị trong @angular/fire/fesm2022/angular-fire.mjs, cùng với việc truy cập document trong stack trace Firebase App Check đã được báo cáo. Được xem là hoàn tất khi Angular SSR và prerendering hoàn thành mà không có lỗi document, đồng thời App Check vẫn tiếp tục được khởi tạo trong trình duyệt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Version info

Angular:
17.0.8

Firebase:
10.7.1

AngularFire:
17.0.0

Other (e.g. Ionic/Cordova, Node, browser, operating system):
Node 18, Ionic 7, MacOS

How to reproduce these conditions

Steps to set up and reproduce

  1. New Angular 17 project
  2. ng add @angular/fire@17
  3. ng add @angular/ssr
  4. Set up App Check as per https://github.com/angular/angularfire/blob/master/docs/app-check.md
  5. ng build
Debug output
⠇ Building...
ReferenceError: document is not defined
    at makeDiv (/app/.angular/prerender-root/node_modules/@firebase/app-check/dist/esm/index.esm2017.js:1119:26)
    at initializeV3 (/app/.angular/prerender-root/node_modules/@firebase/app-check/dist/esm/index.esm2017.js:1064:19)
    at _ReCaptchaV3Provider.initialize (/app/.angular/prerender-root/node_modules/@firebase/app-check/dist/esm/index.esm2017.js:1255:9)
    at _activate (/app/.angular/prerender-root/node_modules/@firebase/app-check/dist/esm/index.esm2017.js:1543:20)
    at initializeAppCheck (/app/.angular/prerender-root/node_modules/@firebase/app-check/dist/esm/index.esm2017.js:1498:5)
    at <anonymous> (app/.angular/prerender-root/c56c3be0-e454-4b23-bf7d-d028ecf276ec/node_modules/@angular/fire/fesm2022/angular-fire.mjs:216:44)
    at <anonymous> (/app/.angular/prerender-root/c56c3be0-e454-4b23-bf7d-d028ecf276ec/node_modules/@angular/fire/fesm2022/angular-fire.mjs:148:57)
    at _ZoneDelegate.invoke (/app/.angular/prerender-root/node_modules/zone.js/fesm2015/zone.js:368:26)
    at _Zone.run (/app/.angular/prerender-root/node_modules/zone.js/fesm2015/zone.js:129:43)
    at _NgZone.runOutsideAngular (/app/.angular/prerender-root/node_modules/@angular/core/fesm2022/core.mjs:1461
An unhandled exception occurred: document is not defined
Expected behavior

AngularFire should check if rendering on a browser before calling App Check code and RecaptchaV3 (which relies on document being available)

Actual behavior

No check is done, so when providing App Check, this above error occurs as soon as pre-rendering on the server happens and document is accessed but isn't available due to not running in a browser

Ngôn ngữ chính
TypeScript
Star
7.8k
Fork
2.2k
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
5

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của angular/angularfire

Tất cả issue của angular/angularfire

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.