eugelogic / gatsby-press

Gatsby with Headless WordPress
https://www.gatsbypress.co.uk/
MIT License
1 stars 0 forks source link

Use ENV for some configuration settings #56

Closed crgeary closed 4 years ago

crgeary commented 4 years ago

Consider using ENV variables for some of your configuration settings. For example, the WP URL.

This allows people to switch out different settings between development, staging and production should they need to (which is quite often a yes).

It's also a good place to store API keys as the ENV variables should NOT be uploaded to the repository.

I would recommend you use the .env file for local, and your hosts ENV options on production. Ensure you do not commit .env to your repo though.

eugelogic commented 4 years ago

This was only partially implemented on https://github.com/eugelogic/gatsby-press/commit/b3248182948a9f2a936a32aee21248eaaf402b52 and https://github.com/eugelogic/gatsby-press/commit/ef2dc290d323b6b84cfba490daf897d1accc9cd3

It could not be implemented in the /utils/index.js file because the createLocalLink function runs in the browser, not on the server side (at least in dev mode) and you cannot access ENV in the browser by default for security purposes.

There is an issue on hold which should take care of that stray url by removing it altogether.