Gatsby: Endpoint not found after gatsby-source-contentful edit

Created on 9 Oct 2019  路  8Comments  路  Source: gatsbyjs/gatsby

Description

After commit fdd57d3 I'm unable to run gatsby build. The error I get is "Endpoint not found. Check if host and spaceId settings are correct". Reverting gatsby-source-contentful to 2.1.41 fixes the problem.

Steps to reproduce

Run yarn upgrade --latest and then gatsby build.

Expected result

Gatsby should build.

Actual result

Get the error:
ERROR

Accessing your Contentful space failed.
Try setting GATSBY_CONTENTFUL_OFFLINE=true to see if we can serve from cache.

Endpoint not found. Check if host and spaceId settings are correct

Environment

System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Shell: 3.0.2 - /usr/local/bin/fish
Binaries:
Node: 12.8.0 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.10.3 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/local/bin/python
Browsers:
Chrome: 77.0.3865.90
Firefox: 68.0.1
Safari: 13.0.1
npmPackages:
gatsby: ^2.15.21 => 2.15.34
gatsby-image: ^2.2.20 => 2.2.25
gatsby-plugin-manifest: ^2.2.18 => 2.2.21
gatsby-plugin-offline: 3.0.13 => 3.0.13
gatsby-plugin-react-helmet: ^3.1.8 => 3.1.11
gatsby-plugin-sharp: ^2.2.25 => 2.2.29
gatsby-plugin-styled-components: ^3.1.6 => 3.1.9
gatsby-plugin-transition-link: ^1.13.0 => 1.13.0
gatsby-source-contentful: ^2.1.41 => 2.1.47
gatsby-source-filesystem: ^2.1.26 => 2.1.31
gatsby-transformer-sharp: ^2.2.14 => 2.2.21
npmGlobalPackages:
gatsby-cli: 2.7.30

needs reproduction

Most helpful comment

The issue still occurred on our staging branch, because the staging API key didn't have access to master. See #19392

All 8 comments

Was having the same issue and it got me on the verge of tearing my hair out :rofl:

Turns out, for whatever weird reason, I had the CONTENTFUL_ACCESS_TOKEN variable added at a system level. I'm using dotenv in my project, but since I have the variable stored at the system, it was using the system one, and obviously, it failed to connect with that wrong access token.

Just thought I'd give a shout out in case something similar is happening to you. Try logging the AccessToken in the console and see if it's passing the correct one. :slightly_smiling_face:

Trying to update from 2.1.44 to 2.1.49 and getting the same issue. Nothing in the changelog seemed to mention a difference in pulling access tokens or IDs.

10:49:25 AM: error Accessing your Contentful space failed.
10:49:25 AM: Try setting GATSBY_CONTENTFUL_OFFLINE=true to see if we can serve from cache.
10:49:25 AM: Endpoint not found. Check if host and spaceId settings are correct
10:49:25 AM: Used options:
10:49:25 AM: host: "cdn.contentful.com" - Check if setting is correct
10:49:25 AM: spaceId: "*********" - Check if setting is correct
10:49:25 AM: accessToken: "************************************************************"

FWIW, the above spaceId, accessToken and host are all correct. Nothing has changed in our code except for this package bump. It only started breaking on this new patch version.

As of writing, the Contentful Delivery API is having issues, so that may be the cause: https://www.contentfulstatus.com/

Here is my gatsby info --clipboard:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.13.0 - /usr/local/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.1.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 77.0.3865.90
    Firefox: 68.0.2
    Safari: 13.0.2
  npmPackages:
    gatsby: ^2.16.1 => 2.16.1
    gatsby-image: ^2.2.29 => 2.2.29
    gatsby-plugin-canonical-urls: ^2.1.13 => 2.1.13
    gatsby-plugin-catch-links: ^2.1.15 => 2.1.15
    gatsby-plugin-compile-es6-packages: ^2.1.0 => 2.1.0
    gatsby-plugin-layout: ^1.1.13 => 1.1.13
    gatsby-plugin-manifest: ^2.2.23 => 2.2.23
    gatsby-plugin-netlify: ^2.1.21 => 2.1.21
    gatsby-plugin-react-helmet: ^3.1.13 => 3.1.13
    gatsby-plugin-react-svg: ^2.1.2 => 2.1.2
    gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0
    gatsby-plugin-remove-trailing-slashes: ^2.1.12 => 2.1.12
    gatsby-plugin-robots-txt: ^1.5.0 => 1.5.0
    gatsby-plugin-sass: ^2.1.20 => 2.1.20
    gatsby-plugin-segment-js: ^3.0.1 => 3.0.1
    gatsby-plugin-sharp: ^2.2.31 => 2.2.31
    gatsby-plugin-sitemap: ^2.2.19 => 2.2.19
    gatsby-plugin-styled-components: ^3.1.11 => 3.1.11
    gatsby-remark-images-contentful: ^2.1.20 => 2.1.20
    gatsby-remark-prismjs: ^3.3.20 => 3.3.20
    gatsby-source-contentful: ^2.1.49 => 2.1.49
    gatsby-transformer-json: ^2.2.15 => 2.2.15
    gatsby-transformer-remark: ^2.6.30 => 2.6.30
    gatsby-transformer-sharp: ^2.2.23 => 2.2.23
  npmGlobalPackages:
    gatsby-cli: 1.1.58

This seems to be fixed in the latest version of gatsby-source-contentful.

The issue still occurred on our staging branch, because the staging API key didn't have access to master. See #19392

Ran into the same error today after creating a new branch on contentful and editing gatsby-source-contentful. As @jordan314 mentioned, the problem was the API key.

Make sure to give your API key access to the branch by checking the checkbox on the bottom in Contentful: settings --> api keys --> [yourKey]

Sorry, not really following what's going on here. I've set up Gatsby Cloud with the same contentfull env variables I'm successfully using in Netlify.

Now when making PR's into my development branch on Github the Gatsby Build Service is failing.

I'm facing this issue using Gatsby Cloud's Preview service. It works perfectly on my computer when I do gatsby build, and the actual build created by Gatsby Cloud works.

However, the Preview feature says I don't have access to Contentful in the error logs, citing this same bug. It's odd since I added my environment variables and did the Contentful integration.

It would appear that Gatsby Preview is using the contentful build endpoint (cdn.contentful.com) rather than the preview endpoint (preview.contentful.com) from contentful, even though I have properly configured them. Not sure if this is the best issue for this error, but it was the only place I found it previously discussed.

Not sure if this helps anyone but I solved this issue by changing the name of my content models.
I had (first letter lowercase and camelcase):
exampleItem
exampleProduct
Changed it to (capitalized camelcase):
ExampleItem
ExampleProduct

I think this has something to do with the space having the same name as the Contentful "Content Type Id" which had a lowercase first letter for the camelcase naming.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benstr picture benstr  路  3Comments

brandonmp picture brandonmp  路  3Comments

hobochild picture hobochild  路  3Comments

rossPatton picture rossPatton  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments