Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
154
rated 0 times [  157] [ 3]  / answers: 1 / hits: 19202  / 12 Years ago, fri, november 2, 2012, 12:00:00

I have a node app that has a line like this:



var ip = process.env.IP || 'http://localhost';


I am using it with passport-facebook node package to define the callback from Facebook authentication:



passport.use(new FacebookStrategy({
clientID: FACEBOOK_APP_ID,
clientSecret: FACEBOOK_APP_SECRET,
callbackURL: ip + : + port + /auth/facebook/callback
},
function(accessToken, refreshToken, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
return done(null, profile);
});
}
));


It seems that Heroku doesn't know process.env.IP so I went ahead and defined a config var in Heroku:



heroku config:add process.env.IP=http://app.mydomain.com


Debugging the server I see that ip is not what I want but it's http://localhost same as I defined as the fallback in the first line of code.



How do I get node to read the config var correctly from heroku ?


More From » node.js

 Answers
79

You want to use heroku config:set IP=http://app.mydomain.com; it defines an environment variable called IP, which you access in Node.js via process.env.IP. See Setting up config vars for a deployed application for more information.


[#82230] Thursday, November 1, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
carolynt

Total Points: 252
Total Questions: 98
Total Answers: 109

Location: French Southern and Antarctic Lands
Member since Sat, Oct 31, 2020
4 Years ago
;