Access env.var and options inside app


#1

Hello folks,

I was going to implement this feature request on ostrio:files package. But stuck with a question:

How to access next options and env.vars inside application at Server and Client?:

  1. MOBILE_ROOT_URL
  2. MOBILE_DDP_URL
  3. --mobile-server argument

I’m sorry if this question is obvious, but for some reason, I cannot figure this out. I was 100% sure it will be placed into __meteor_runtime_config__, but it isn’t.

Thanks in advance.


#2

Just guessing: I think the —mobile-server option is not really accessible in client code as it is used at compile time by cordova. After that it is the root url i guess. Maybe those env vars behave the same. The client code in the app connects to a localhost 127.* ip webserver once it is started and does not need to know these settings.


#3

Good guess, thank you.

I’m looking for reference or tested code sample.
Hopefully someone who are building Cordova app on daily basis could step-in.


#4

You should be able to get the mobile-server config on the server with process.env.MOBILE_ROOT_URL at startup and on the client with meteor_runtime_config.ROOT_URL in Meteor.isCordova mode.