I have a .env file:
REACT_APP_URL={value}
REACT_APP_API_URL={value}
REACT_APP_VEHICLE_IMAGE_URL={value}
REACT_APP_NAME={value}
REACT_APP_GA_TRACKING_ID={value}
REACT_APP_WEBSITE_URL={value}
That is my current file of eas.json
:
{
"cli": {
"version": ">= 10.0.2"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"ios": {
"simulator": true
}
},
"preview": {
"distribution": "internal"
},
"production": {}
},
"submit": {
"production": {}
}
}
I have stored these values in eas secret by running the command:
eas secret:push --scope project --env-file .env
I have stored on env some secret but the problem is when I run the app the env values are not stored in the build
when i run eas build --platform android --non-interactive --no-wait
I get this:
Loaded "env" configuration for the "production" profile: no environment variables specified
How can i load the env from the eas secret I have added, so when i build i can run the application with those variables?
2
Answers
Expo environment variables
Actually, your
.env
file should contain the variables like the following:And inside your codes, you can use the variables like the following:
For more information about using Expo environment variables you can read this link.
HINT: Use the exact phrase
process.env.EXPO_PUBLIC_XXX
to get the variable from the.env
file. The_XXX
is your custom name.EAS Build
To have a correct EAS Build you should write the
eas.json
file like the following:To have a better understanding of EAS Build configuration you can have a look at this link.
Store the secrets in eas secrets
Update your eas.json like this
}
On eas build –platform ios. Ensure it says
Loaded "env" configuration for the "production" profile:
Test and ensure it works
I was struggled to get the env injection working too. This ensure safety for the env variable. Hope this helps