admin管理员组

文章数量:1122846

I am using Expo's EAS Build and have learned there are three ways to define environment variables:

  1. eas.json: Adding the variables directly in the env property of each build profile.
  2. EAS Secrets: Storing sensitive variables securely using the eas secret:create command.
  3. Command-line flag: Passing variables with the --env flag during the build command.

I want to confirm the priority when these methods are used simultaneously. For example:

  • If I define the same variable (API_URL) in both eas.json and EAS Secrets, which one will take precedence?
  • If I use the --env flag, will it override the other two?

Additionally, I'd like to know the best practices for managing environment variables, especially in cases where:

  • I have sensitive keys (e.g., API keys).
  • I need to differentiate between development and production environments.

I am using Expo's EAS Build and have learned there are three ways to define environment variables:

  1. eas.json: Adding the variables directly in the env property of each build profile.
  2. EAS Secrets: Storing sensitive variables securely using the eas secret:create command.
  3. Command-line flag: Passing variables with the --env flag during the build command.

I want to confirm the priority when these methods are used simultaneously. For example:

  • If I define the same variable (API_URL) in both eas.json and EAS Secrets, which one will take precedence?
  • If I use the --env flag, will it override the other two?

Additionally, I'd like to know the best practices for managing environment variables, especially in cases where:

  • I have sensitive keys (e.g., API keys).
  • I need to differentiate between development and production environments.
Share Improve this question edited Nov 22, 2024 at 12:44 jonrsharpe 122k30 gold badges263 silver badges470 bronze badges asked Nov 22, 2024 at 12:40 GyoGyo 579 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

EAS Secrets is where you should put all your env variable at the end (as CI-CD pipeline) and is the one that will overwrite others values.

--env and the env object in eas.json are the same thing.

about sensitiveness, it's depend which level of security you want to put on your variable in the EAS Secrets variables manager (visible, masked or secret). Secret level is for value you don't want either other people on your team to see or leak by mistake.

Sensitive data such as API KEY should be stored at least at masked level.

You can restrict you variable on specific environnement in EAS Secrets, which let's you configure them more efficiently.

Also a little warn, if you put data on masked or secrets level, be sure to not use them with EXPO_PUBLIC_ prefix in your app, else it will be visible for anyone who install your application.

本文标签: