This PR normalizes on conventions in Gatsby around environment variable naming and fixes some "foot guns" that many users have run into in configuring preview vs. publish environments. Specifically, it does this by unifying around consistent environment variable patterns that swap based on environment:
CONTENTFUL_ACCESS_TOKEN: this is the access token (either Content Delivery API or Content Preview API for Preview)
CONTENTFUL_SPACE_ID: no change here, but the space id which is the same between both
CONTENTFUL_HOST: if using the Content Preview API this has to be preview.contentful.com otherwise if unset it defaults to the Content Delivery API CDN
I also augmented the script to clarify this with the .env files that are written.
Context
This will solve a lot of issues for Contentful and Gatsby users, specifically those that are struggling with setting up consistent environment variables. In fact, this is one of the more common reasons that builds and previews fail on Gatsby Cloud.
What was previously multiple paths (e.g. I have to set HOST, and if I set HOST I have to also set CONTENTFUL_PREVIEW_ACCESS_TOKEN) is now just augmented with consistent environment variables.
Description
This PR normalizes on conventions in Gatsby around environment variable naming and fixes some "foot guns" that many users have run into in configuring preview vs. publish environments. Specifically, it does this by unifying around consistent environment variable patterns that swap based on environment:
CONTENTFUL_ACCESS_TOKEN
: this is the access token (either Content Delivery API or Content Preview API for Preview)CONTENTFUL_SPACE_ID
: no change here, but the space id which is the same between bothCONTENTFUL_HOST
: if using the Content Preview API this has to bepreview.contentful.com
otherwise if unset it defaults to the Content Delivery API CDNI also augmented the script to clarify this with the .env files that are written.
Context
This will solve a lot of issues for Contentful and Gatsby users, specifically those that are struggling with setting up consistent environment variables. In fact, this is one of the more common reasons that builds and previews fail on Gatsby Cloud.
What was previously multiple paths (e.g. I have to set HOST, and if I set HOST I have to also set CONTENTFUL_PREVIEW_ACCESS_TOKEN) is now just augmented with consistent environment variables.