Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "app.firestore is not a function" when getting data from Firestore in SSR app

I have currently followed a video on youtube on SSR with firebase functions. And that seems to work perfect. Now i am trying to add some additional functionality to my ssr boilerplate app. I want to add Firebase firestore support so i can get data from firebase firestore. I am getting this error ERROR { Error: Uncaught (in promise): TypeError: app.firestore is not a function and this only happens in the function (server). Data is retrieved in the frontend but the SSR part is not working because of the function (server) error. I cant seem to find any solution for this. My code can be viewed here: Github_Repository

I cant see what i am missing here and hope posting this question will help.

thanks.

like image 223
Lahib Avatar asked Nov 07 '22 07:11

Lahib


1 Answers

Use externalDependencies = [ "@firebase/app", "@firebase/firestore" ] in angular.json file

Below is the code.

"server": {
      "builder": "@angular-devkit/build-angular:server",
      "options": {
        "outputPath": "dist/market-web/server",
        "main": "server.ts",
        "tsConfig": "tsconfig.server.json",
        "externalDependencies": [
          "@firebase/app",
          "@firebase/firestore"
        ]
      },
  .....
like image 155
Aman Jain Avatar answered Nov 15 '22 08:11

Aman Jain