When I try to connect to Contentful with Gatsby, I get this error message :
Starting to fetch data from Contentful
info Fetching default locale
ERROR
Accessing your Contentful space failed.
Try setting GATSBY_CONTENTFUL_OFFLINE=true to see if we can serve from cache.
Used options:
spaceId: "*******ed"
accessToken: "*******ed"
host (default value): "cdn.contentful.com"
environment (default value): "master"
downloadLocal (default value): false
localeFilter (default value): [Function]
forceFullSync (default value): false
pageLimit (default value): 100
useNameForId (default value): true
not finished source and transform nodes - 0.320s
My code in gatsby-config.js :
module.exports = {
siteMetadata: {
title: `Gatsby`,
siteUrl: `http://localhost8000`,
author: '****',
},
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: ${`process.env.CONTENTFUL_SPACE_ID`},
accessToken: ${`process.env.CONTENTFUL_ACCESS_TOKEN`},
// My code only works with this syntax ${`...`}
}
},
]
}
I saw Brent Arias's response on this page: https://stackoverflow.com/questions/60892938/ Accessing your Contentful space failed with gatsby-source-contentful. He overwrites and creates the contentful space, and locally relaunches the starter script "rg-portfolio" which natively contains a contentful configuration. It also refers to a "contentful-data.json" file in the starter.
I use the "hello world" starter, so I added the gatsby-source-contentful plugin myself, and it didn't create a "contentful-data.json" file, and I don't see anything about this json file on the plugin's documentation. I deleted and recreated my contentful space, then I reinstalled the plugin, but it still doesn't work ...
Any idea?