Pretty sure I might be making some mistake here but let’s see.
Managed Worfklow
EXPO SDK 44
EAS-CLI 0.48
I currently have a .env file with keys like so
API_KEY=xxxxx
API_KEY_STAGING=xxxxx
AUTH_DOMAIN=xxxxx
AUTH_DOMAIN_STAGING=xxxxx
PROJECT_ID=xxxxx
PROJECT_ID_STAGING=xxxxx
STORAGE_BUCKET=xxxxx
STORAGE_BUCKET_STAGING=xxxxx
MESSAGING_SENDER_ID=xxxxx
MESSAGING_SENDER_ID_STAGING=xxxxx
APP_ID=xxxxx
APP_ID_STAGING=xxxxx
MEASUREMENT_ID=xxxxx
MEASUREMENT_ID_STAGING=xxxxx
and my eas.json
{
"cli": {
"version": ">= 0.37.0"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"development-simulator": {
"developmentClient": true,
"distribution": "internal",
"ios": {
"simulator": true
}
},
"preview": {
"android": {
"buildType": "apk",
"gradleCommand": ":app:assembleRelease"
}
},
"preview-prod": {
"distribution": "internal",
"android": {
"buildType": "apk",
"gradleCommand": ":app:assembleRelease"
},
"env": {
"APP_ENV": "production"
},
"channel": "preview"
},
"production": {
"channel": "preview",
"node": "14.16.0",
"env": {
"APP_ENV": "production"
}
}
},
"submit": {
"production": {}
}
}
and my app.config.js is below
import 'dotenv/config'
let Config = {
apiKey: process.env.API_KEY_STAGING,
authDomain: process.env.AUTH_DOMAIN_STAGING,
projectId: process.env.PROJECT_ID_STAGING,
storageBucket: process.env.STORAGE_BUCKET_STAGING,
messagingSenderId: process.env.MESSAGING_SENDER_ID_STAGING,
appId: process.env.APP_ID_STAGING,
measurementId: process.env.MEASUREMENT_ID_STAGING,
}
if (process.env.APP_ENV === 'production') {
Config.apiKey = process.env.API_KEY
Config.authDomain = process.env.AUTH_DOMAIN
Config.projectId = process.env.PROJECT_ID
Config.storageBucket = process.env.STORAGE_BUCKET
Config.messagingSenderId = process.env.MESSAGING_SENDER_ID
Config.appId = process.env.APP_ID
Config.measurementId = process.env.MEASUREMENT_ID
} else {
Config.apiKey = process.env.API_KEY_STAGING
Config.authDomain = process.env.AUTH_DOMAIN_STAGING
Config.projectId = process.env.PROJECT_ID_STAGING
Config.storageBucket = process.env.STORAGE_BUCKET_STAGING
Config.messagingSenderId = process.env.MESSAGING_SENDER_ID_STAGING
Config.appId = process.env.APP_ID_STAGING
Config.measurementId = process.env.MEASUREMENT_ID_STAGING
}
export default {
....
extra: {
...Config,
},
}
After adding the non _STAGING keys to eas secrets for production use, I try doing a development build to keep developing locally with the _STAGING keys.
Currently, I am getting errors such as (FirebaseError: Firebase: Error (auth/invalid-api-key)) which I believe is related to my eas build --profile development not picking up the correct environment variables for the development.
Any ideas on where I could be going wrong here with providing the right environment variables for a development build ?
How do I ensure that eas secret keys don’t interfere with my local development builds ?
Please advise.