XervoIO / demeteorizer

Converts a Meteor app into a standard Node.js application.
http://npm.im/demeteorizer
MIT License
703 stars 59 forks source link

trying to pass env variables to deployed app #263

Closed w3jimmy closed 7 years ago

w3jimmy commented 7 years ago

Hi, I'm trying to pass env variables to the deployed app but I'm not succeeding.

I can deploy the app and run using the required server variables (ROOT_URL, MONGO_URL, PORT) butI have a few "switches" in my app where the code changes depending on a few server variables, for example: CUSTOM_DEBUG=true and API_HOST=xxx.xxx.xxx.xxx

Is there a way to do this? And what is the correct way of doing so?

I've tried editing the final npm start script but didn't make any difference. Thanks

fiveisprime commented 7 years ago

What platform are you running this on? The syntax is different on Windows

SET CUSTOM_DEBUG=true
SET ROOT_URL=http://localhost:8080
SET MONGO_URL=mongodb://localhost:27017/test
npm start

To do that in your start script do something like

{
  "start": "SET CUSTOM_DEBUG=true && SET ROOT_URL=http://localhost:8080 && SET MONGO_URL=mongodb://localhost:27017/test && node ../../main"
}

That works in cmd and PowerShell, but won't work the same if you are using the Git Shell.

It's also worth checking out cross-env if you need this to work in multiple environments.

w3jimmy commented 7 years ago

thanks @fiveisprime. I'm running in Mac OS X. I will try this approach in the next few minutes

fiveisprime commented 7 years ago

Ahh, on OSX, it looks like this

{
  "start": "CUSTOM_DEBUG=true ROOT_URL=http://localhost:8080 MONGO_URL=mongodb://localhost:27017/test node ../../main"
}
w3jimmy commented 7 years ago

This is still not working for me. location: bundle/programs/server/

I tried: 1. CUSTOM_DEBUG=true ROOT_URL=http://localhost:8080 MONGO_URL=mongodb://localhost:27017/test node ../../main 2. CUSTOM_DEBUG=true ROOT_URL=http://localhost:8080 MONGO_URL=mongodb://localhost:27017/test && node ../../main 3. export CUSTOM_DEBUG=true ROOT_URL=http://localhost:8080 MONGO_URL=mongodb://localhost:27017/test && node ../../main

In all of the cases only CUSTOM_DEBUG is not being detected by the app

what could I be missing?

fiveisprime commented 7 years ago

That first one is correct. How are you testing for CUSTOM_DEBUG in your app?

w3jimmy commented 7 years ago

I finally made it work, but only using cross-env. Inside my app I access to it with process.env.CUSTOM_DEBUG

fiveisprime commented 7 years ago

Weird, but glad you got it working!