PLEASE help us help you by writing a good post!
Site name is Could you please help me sort out this same issue with my sites too? My sites are deploying fine but none of my environment variables are logging properly.
I have followed the recommended article and I am using REACT_APP… because my project is built using Create-React-App.
My site name is: sendt-dev.netlify.app
My CI/CD setup is git => circleCI => netlify
My issue is with the environment variables set in Netlify UI are not available in my production deployment.
Locally, I use .env and .env.development and .env.production and these are displaying the variables correctly but it is not working on the deployed live Netlify site. When logging process.env, all my expected env vars are undefined
My .env file is as follows (I’ve starred out the actual values)
REACT_APP_API_BASE_URL=******
REACT_APP_BASE_URL=******
REACT_APP_ENV=******
REACT_APP_FIREBASE_API_KEY=******
REACT_APP_FIREBASE_AUTH_DOMAIN=******
REACT_APP_FIREBASE_PROJECTID=******
REACT_APP_FIREBASE_STORAGE_BUCKET=******
REACT_APP_FIREBASE_SENDER_ID=******
REACT_APP_FIREBASE_APP_ID=******
REACT_APP_FIREBASE_MEASUREMENT_ID=******
REACT_APP_SENTRY_API_KEY=******
REACT_APP_STRIPE_PUBLISHABLE_KEY=******
I am using REACT_APP prefix becuase I am using create-react-app for my project. I have used these same names in Netlify ENV UI.
My CircleCI config.yml is as follows:
executors:
node-executor:
docker:
- image: cimg/node:14.18.2
jobs:
build-deploy-dev:
executor: node-executor
steps:
- checkout
- run:
name: Install Dependencies
command: yarn install
- run:
name: Build Dev
command: CI=false yarn run build
- run:
name: Install Netlify
command: sudo yarn global add netlify-cli
- run:
name: Netlify Deploy
command: |
netlify deploy --site $NETLIFY_DEV_SITE_ID --auth $NETLIFY_ACCESS_TOKEN --prod --dir=build
build-deploy-prod:
executor: node-executor
steps:
- checkout
- run:
name: Install Dependencies
command: yarn install
- run:
name: Build Prod
command: CI=false yarn run build
- run:
name: Install Netlify
command: sudo yarn global add netlify-cli
- run:
name: Netlify Deploy
command: netlify deploy --site $NETLIFY_PROD_SITE_ID --auth $NETLIFY_ACCESS_TOKEN --prod --dir=build
version: 2.1
workflows:
version: 2
build-deploy:
jobs:
- build-deploy-dev:
context: SENDTDEV
- hold:
type: approval
requires:
- build-deploy-dev
- build-deploy-prod:
context: SENDTPROD
requires:
- hold
Please can someone give me some ideas of how to solve this?
I have gone through the Netlify post on troubleshooting environment variables but I cant quite sort it out and it’s been quite a few days now trying to solve this.
Any help is much appreciated