EAS build not getting correct "extra" parameters

Hi all, just looking for some held debugging why my app seems to be receiving the wrong parameters…

I have an extra section in my app.json with these sections for api and auth:

{
  "expo": {
    ...
    "extra": {
      "api": {
        "host": ""
      },
      "auth": {
        "useEmulator": false,
        "emulatorHost": ""
      }
    }
  }
}

Then I update these extra parameters via the app.config.js file:

My eas.json doesn’t seem too complicated, and follows this guide for choosing the correct environment in the app.config.js at build/runtime:

{
  "cli": {
    "version": ">= 0.46.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "env": {
        "APP_ENV": "dev"
      }
    },
    "preview": {
      "developmentClient": true,
      "distribution": "internal",
      "env": {
        "APP_ENV": "preview"
      }
    },
    "production": {}
  },
  "submit": {
    "production": {}
  }
}

Finally, in my app I consume these parameters via this getConfig() method (the x parameter and the console.log are just there for my debugging):

import Constants from 'expo-constants';

export function getConfig() {
    const x = {
        apiHost: Constants.expoConfig.extra.api.host,
        useEmulator: Constants.expoConfig.extra.auth.useEmulator,
        authEmulatorUrl: Constants.expoConfig.extra.auth.emulatorHost,
    };
    
    console.log(x);
    
    return x;
}

However of course here’s the interesting part… I

  1. Run a build for the preview envionment using eas build --profile preview --platform ios
  2. Download the built app onto my iPhone
  3. Do an expo start --dev-client on my local machine
  4. Open the app on my iPhone and connect to the dev client just over my home network.
  5. Once the app has built, it obviously loads up but the confusing bit as that the console.log statement above shows all the parameters from the dev section of app.config.js instead of the preview section.

Does anyone have any suggestions as to what I may be doing wrong, or how to debug this further?
Thanks in advance!

Hi @matt_is_flat

Try:

APP_ENV=preview npx expo start --dev-client

(Or if you’re on Windows, npx cross-env APP_ENV=preview npx expo start --dev-client)

1 Like

Ah of course - the only time I forgot to actually check the environment was being set properly :roll_eyes: Thanks heaps!

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.