Expo - process.env.API_URL returns undefined

Viewed 255

Im using process.env.API_URL to try and grab my api URL from eas.json file but it keeps returning "undefined". Below is my eas.json and the code I am using to grab both API_URL and API_KEY:

{
  "build": {
    "release": {},
    "production": {
      "env": {
        "API_KEY": "myapikey",
        "API_URL": "https://api.my.com"
      }
    },
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "env": {
        "API_KEY": "myapikey",
        "API_URL": "https://staging-api.my.com"
      }
    }
  },
  "submit": {
    "release": {
      "android": {
        "serviceAccountKeyPath": "../path/to/api-xxx-yyy-zzz.json",
        "track": "internal"
      }
    }
  }
}
const apiKey = process.env.API_KEY;
const apiURL = process.env.API_URL;

console.logging the apiKey returns the correct value however console.logging apiURL returns "undefined"

I followed the example that the Expo docs show here: https://docs.expo.dev/guides/environment-variables/

Why would API_KEY return fine but API_URL be undefined? Ive restarted Expo and cleared cache and the problem still persists.

0 Answers
Related