Closed coreybruyere closed 4 years ago
Are you running into this issue locally during development or during a triggered build elsewhere? According to the documentation when you run gatsby build
or gatsby serve
you'll be in the context of a production environment and gatsby will be looking for a .env.production
file to pull your Contentful values from. Is that what you have configured?
Ok that makes sense. I'm trying to debug an issue I'm having with Gatsby Cloud where the same env varaibles I'm passing into Netlify don't seem to be working when building in Gatsby Cloud.
This is the specific error. The first part of the error is an error message I'm returning if access token and spaceId aren't defined... but they are. Trying to follow an issue here but not following what's happening and why my builds are failing through Gatsby cloud.
Accessing your Contentful space failed.
Try setting GATSBY_CONTENTFUL_OFFLINE=true to see if we can serve from cache.
Authorization error. Check if accessToken and environment are correct Used options: spaceId: "************" accessToken: "****************************************************************" -
Check if setting is correct host (default value): "cdn.contentful.com" environment (default value): "master" -
Check if setting is correct downloadLocal (default value): false localeFilter (default value): [Function] forceFullSync (default value): false
Sounds like a straight forward error, but I'm defining .env variables locally using production and development vars for
CONTENTFUL_SPACE_ID
,CONTENTFUL_ACCESS_TOKEN
,CONTENTFUL_HOST
.Only running into this issue when trying to run
gatsby build
followed bygatsby serve
. Any ideas as to why my API keys from Contentful can't be read when trying to serve locally? I can share my repo if needed.