मैं एक्सप्रेस के साथ पासपोर्ट के लिए पासपोर्ट-लिंक्डइन रणनीति का उपयोग कर रहा हूं, ताकि उपयोगकर्ता अपनी लिंक्डइन प्रोफाइल में लॉग इन कर सकें।पासपोर्ट रणनीति callbackURL के लिए वर्तमान होस्ट कैसे सेट करें?
passport.use(new LinkedInStrategy({
consumerKey: config.linkedin.LINKEDIN_API_KEY,
consumerSecret: config.linkedin.LINKEDIN_SECRET_KEY,
callbackURL: "http://localhost:3000/auth/linkedin/callback"
},
function(token, tokenSecret, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function() {
// To keep the example simple, the user's LinkedIn profile is returned to
// represent the logged-in user. In a typical application, you would want
// to associate the LinkedIn account with a user record in your database,
// and return that user instead.
return done(null, profile);
});
}
));
लाइन 4 पर, मैं मैन्युअल रूप से पूर्ण कॉलबैक URL सेट करने के लिए:
मैं निम्नलिखित कोड है। मेरे पास उत्पादन के लिए एक स्ट्रिंग थी और विकास के लिए एक था, लेकिन मेरे यूआरएल बदलते रहते हैं, और बंदरगाह करते हैं (मैं विकसित करने के लिए 2 मशीनों का उपयोग करता हूं)।
मैं URL (http://localhost:3000
) का पहला भाग स्वचालित रूप से कैसे सेट कर सकता हूं? क्या express
या app
की कोई संपत्ति है जो मुझे ऐसा करने की अनुमति देगी? क्या मुझे app.use(function(req, res){});
का सहारा लेना है?
धन्यवाद!
यदि आपका ऐप रूट पथ पर नहीं चल रहा है, तो यह काम नहीं करता है, उदाहरण के लिए यह '/' के बजाय '/ myapp' पर चल रहा है। –