Expo EAS build not exposing secrets when being accessed with `process.env.X`

Viewed 954

I have tried to create secrets for my Expo app using both the EAS CLI and the Expo website, according to the documentation:https://docs.expo.dev/build-reference/variables/. However, after I have made an EAS build for Android with the command: eas build -p android --profile <profile_name>, and run it through the installation link on my physical Android device.

It seems that when I try to view the secrets through process.env.VARIABLE_NAME (Through alerts), it just gives me undefined.

I was wondering if anyone have faced this issue before and perhaps found a solution? Thank you in advance.

1 Answers

I was having the same issue. I looked at the logs in the expo website and I could see under the "spin up build environment" section that the secrets were being exposed during the build. Problem is, that expo does not automatically inject the secret values under the process.env variables. In order to catch these values you can use a tool such as the babel plugin transform-inline-environment-variables.

Related