user18150656
user18150656

Reputation: 125

ERROR #11321 PLUGIN "gatsby-source-strapi" threw an error while running the sourceNodes

I am running my strapi on production server, and this is my code in gatsby-config:

{
      resolve: `gatsby-source-strapi`,
      options: {
        apiURL: `http://strapi.myserver.com/api`,
        queryLimit: 1000, // Default to 100
        collectionTypes: [`Career`],
        token: 'mytoken'
      },
    }

My apis are working correctly when I go to http://strapi.myserver.com/api/careers however graphiQL doesn't see them, also when I run gatsby develop it throws these errors:

ERROR #11321  PLUGIN

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

Request failed with status code 404



ERROR #11321  PLUGIN

"@relate-app/gatsby-source-strapi" threw an error while running the createSchemaCustomization lifecycle:

request to http://strapi.myserver.com/api/graphql failed, reason: getaddrinfo ENOTFOUND strapi.myserver.com

This answer didn't help: (Gatsby-Strapi) Error: Request failed with status code 404

Also my user permissions all of them are checked, my collections are published.

Upvotes: 1

Views: 3413

Answers (4)

Chalindu Dilsara
Chalindu Dilsara

Reputation: 1

{
  resolve: "gatsby-source-strapi",
  options: {
    apiURL: "http://localhost:1337",
    accessToken: "", //add your access token in Settings > API Tokens >  Create new API token >  give permission to all "Find", "FindOne" and give Token Type "Full Access"
    collectionTypes: [
      {
        singularName: "post", // Ex :- if your api like  "http://localhost:1337/api/posts"  
      },
    ],
  },
},

Upvotes: 0

Marcelino Sileoni
Marcelino Sileoni

Reputation: 11

I've tried what you suggested (the token) but didn't work. My environment: Win11

"gatsby": "^5.7.0"
"gatsby-source-strapi": "^3.0.6"
strapi project:  "@strapi/strapi": "4.8.2",

Upvotes: 1

Taras
Taras

Reputation: 1

I'm doing a project with Gatsby - Strapi. And when I tried to connect working Gatsby to Strapi, I had this error:console.log of error

At this moment, I had in gatsby project: "gatsby": "^5.3.3" "gatsby-source-strapi": "^3.0.4".

And in strapi project: "@strapi/strapi": "4.5.5",

I used documentation from gatsby, but in addition to them, I have to add this:

  1. As a MAC user, I have to use this line in config.json for plugin configuration: resolve: gatsby-source-strapi, options: { apiURL: http://127.0.0.1:1337, collectionTypes: [jobs], }, After those lines, I still had a 403 error, but in the browser, I could get a JSON object. To resolve this error, I created API Token, as someone suggested, but with full access. Otherwise, the error doesn't go. I had tried to create a token with read and read one only, but it didn't solve the problem for me.

Upvotes: 0

Filip Koźlicki
Filip Koźlicki

Reputation: 21

You have to change your API token type to "Full access". Go to Settings > Global Settings > API Tokens then click on edit icon in at your API Token and then change token type to "Full access".

Upvotes: 2

Related Questions