contentful-userland / gatsby-contentful-starter

Gatsby starter for a Contentful project from the community.
https://contentful-userland.github.io/gatsby-contentful-starter/
MIT License
279 stars 123 forks source link

Contentful spaceId and access token need to be provided [ERROR #10123 CONFIG] #65

Closed coreybruyere closed 4 years ago

coreybruyere commented 4 years ago

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 by gatsby 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.

raubin commented 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?

coreybruyere commented 4 years ago

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