Go Pro Sign Up Login

Buy Now and unlock this series

$

39

.99

$

32

.99

yours forever

Become a Pro and unlock everything

$

24

.99

per month

Generating Pages From Contentful

This video is about #22 Generating Pages From Contentful - Pro Gatsby

Downloads

Become a pro to download code and videos

Comments

User avatar

Christopher Collins

almost 2 years ago

I would use environment variables in your gatsby-config.js to hide your contentful API accesstoken and spaceid. This can be done by adding this to the top of the file,

require("dotenv").config({
  path: `.env.${process.env.NODE_ENV}`,
})

and then populate the .env file and use the variables like,

{
      resolve: `gatsby-source-contentful`,
      options: {
        spaceId: `${process.env.CONTENTFUL_SPACEID}`,
        accessToken: `${process.env.CONTENTFUL_ACCESS_TOKEN}`,
      },
    },

Want to join the conversation?

Become a Pro member today!