flamelink / gatsby-source-flamelink

Gatsby source plugin for Flamelink
MIT License
8 stars 9 forks source link

Problems with firebase auth #61

Open andreap opened 2 years ago

andreap commented 2 years ago

Hi to all i setted up a little website using gatsby starter blog I've included this code in my gatsby-config.js (within plugins []):

{
      resolve: 'gatsby-source-flamelink',
      options: {
        firebaseConfig: {
          pathToServiceAccount: 'env/key.json',
          databaseURL: '[APPNAME].firebaseio.com',
          storageBucket: '[APPNAME].appspot.com',
          projectId: '[APPNAME]',
          clientEmail: '[REGISTEREDEMAIL]',
        },
        dbType: 'cf',
        environment: 'staging',
        content: true,
        populate: true,
        navigation: true,
        globals: true,
      },
    },

where 'key.json' is the private service account key of my firebase app. I putted it in a folder named 'env' at the same level of gatsby-config.js file.

When I run gatsby develop it gives me some errors:

warn Plugin gatsby-source-flamelink is not compatible with your gatsby version 4.1.0 - It requires gatsby@^2.3.x
warn Plugin gatsby-source-flamelink is not compatible with your gatsby version 4.1.0 - It requires gatsby@^2.3.x
success open and validate gatsby-configs, load plugins - 1.455s
success onPreInit - 0.007s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's no stale data.
success initialize cache - 0.092s
success copy gatsby files - 0.103s
success Compiling Gatsby Functions - 0.430s
success onPreBootstrap - 0.444s
success createSchemaCustomization - 0.014s

 ERROR #11321  PLUGIN

"gatsby-source-flamelink" threw an error while running the sourceNodes lifecycle:

Cannot find module 'env/key.json'
Require stack:
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby-source-flamelink/helpers/api.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby-source-flamelink/gatsby-node.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/bootstrap/load-plugins/load.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/bootstrap/load-plugins/index.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/bootstrap/load-config-and-plugins.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/services/initialize.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/services/index.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/state-machines/develop/services.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/state-machines/develop/index.js
- /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/commands/develop-process.js
- /Users/boplouie/develop/portfolio2021/bs/.cache/tmp-99556-2nUhEUzNsUsQ

  72 |       const startTime = present(); // Initialize Flamelink app
  73 |
> 74 |       const app = api.initApp({
     |                       ^
  75 |         firebaseConfig,
  76 |         environment,
  77 |         dbType

File: node_modules/gatsby-source-flamelink/gatsby-node.js:74:23

  Error: Cannot find module 'env/key.json'
  Require stack:
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby-source-flamelink/helpers/api.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby-source-flamelink/gatsby-node.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/bootstrap/load-plugins/load.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/bootstrap/load-plugins/index.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/bootstrap/load-config-and-plugins.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/services/initialize.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/services/index.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/state-machines/develop/services.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/state-machines/develop/index.js
  - /Users/boplouie/develop/portfolio2021/bs/node_modules/gatsby/dist/commands/develop-process.js
  - /Users/boplouie/develop/portfolio2021/bs/.cache/tmp-99556-2nUhEUzNsUsQ

  - loader.js:880 Function.Module._resolveFilename
    internal/modules/cjs/loader.js:880:15

  - loader.js:725 Function.Module._load
    internal/modules/cjs/loader.js:725:27

  - loader.js:952 Module.require
    internal/modules/cjs/loader.js:952:19

  - v8-compile-cache.js:159 require
    [bs]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - api.js:51 Object.initApp
    [bs]/[gatsby-source-flamelink]/helpers/api.js:51:62

  - gatsby-node.js:74 Object.<anonymous>
    [bs]/[gatsby-source-flamelink]/gatsby-node.js:74:23

  - Generator.next

  - gatsby-node.js:3 asyncGeneratorStep
    [bs]/[gatsby-source-flamelink]/gatsby-node.js:3:103

  - gatsby-node.js:5 _next
    [bs]/[gatsby-source-flamelink]/gatsby-node.js:5:194

  - gatsby-node.js:5 
    [bs]/[gatsby-source-flamelink]/gatsby-node.js:5:364

  - new Promise

  - gatsby-node.js:5 Object.<anonymous>
    [bs]/[gatsby-source-flamelink]/gatsby-node.js:5:97

  - gatsby-node.js:213 Object.sourceNodes
    [bs]/[gatsby-source-flamelink]/gatsby-node.js:213:17

  - api-runner-node.js:430 runAPI
    [bs]/[gatsby]/src/utils/api-runner-node.js:430:22

  - api-runner-node.js:581 Promise.catch.decorateEvent.pluginName
    [bs]/[gatsby]/src/utils/api-runner-node.js:581:13

  - debuggability.js:384 Promise._execute
    [bs]/[bluebird]/js/release/debuggability.js:384:9

warn The gatsby-source-flamelink plugin has generated no Gatsby nodes. Do you need it?
success Checking for changed pages - 0.001s
success source and transform nodes - 0.304s
success building schema - 0.520s
success createPages - 0.074s
success createPagesStatefully - 0.124s
info Total nodes: 68, SitePage nodes: 8 (use --verbose for breakdown)
success Checking for changed pages - 0.001s
success write out redirect data - 0.012s
success Build manifest and related icons - 0.085s
success onPostBootstrap - 0.091s
info bootstrap finished - 6.084s
success onPreExtractQueries - 0.001s
success extract queries from components - 1.698s
success write out requires - 0.007s
success run static queries - 0.011s - 2/2 181.84/s
success run page queries - 0.198s - 3/3 15.16/s
⠀
You can now view gatsby-starter-blog in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use gatsby build
⠀
success Building development bundle - 15.026s
success Writing page-data.json files to public directory - 0.077s - 3/8 104.39/s

warn develop process needs to be restarted to apply the changes to gatsby-config.js
success building schema - 0.391s
success createPages - 0.063s
info Total nodes: 69, SitePage nodes: 8 (use --verbose for breakdown)
success Checking for changed pages - 0.001s
success onPreExtractQueries - 0.001s
success extract queries from components - 0.092s
success write out requires - 0.002s
success run static queries - 0.007s - 2/2 272.77/s
success run page queries - 0.004s - 1/1 234.37/s
success Writing page-data.json files to public directory - 0.007s - 0/5 758.07/s
success building schema - 0.392s
success createPages - 0.051s
info Total nodes: 69, SitePage nodes: 8 (use --verbose for breakdown)
success Checking for changed pages - 0.003s
success onPreExtractQueries - 0.001s
success extract queries from components - 0.067s
success write out requires - 0.001s
success Writing page-data.json files to public directory - 0.007s - 0/5 726.83/s

Can be this warn probably a cause? warn Plugin gatsby-source-flamelink is not compatible with your gatsby version 4.1.0 - It requires gatsby@^2.3.x

I also have read that I can remove the line 'pathToServiceAccount' and insert directly the key in the following way, but it does not work for me too:

{
      resolve: 'gatsby-source-flamelink',
      options: {
        firebaseConfig: {
          privateKey: '-----BEGIN PRIVATE KEY-----KEY HERE-----END PRIVATE KEY-----\n',
          databaseURL: '[APPNAME].firebaseio.com',
          storageBucket: '[APPNAME].appspot.com',
          projectId: '[APPNAME]',
          clientEmail: '[REGISTEREDEMAIL]',
        },
        dbType: 'cf',
        environment: 'staging',
        content: true,
        populate: true,
        navigation: true,
        globals: true,
      },
    },

Can anyone help me? Thank you in advance

ap