contentful-labs / starter-gatsby-blog

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

fix: use consistent env vars #195

Closed DSchau closed 2 years ago

DSchau commented 2 years ago

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:

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.

DSchau commented 2 years ago

@davidfateh worth merging?

DSchau commented 2 years ago

@davidfateh hello! What do you think?

davidfateh commented 2 years ago

Hey sorry for the delay there. Totally missed this!