How Twitter Authentication with Multiple Host Names from the Same Domain Using the Same Twitter Application?

I have two host names that are sent to the same IP address by my DNS:

  • theark.info
  • www.theark.info

I explicitly set my callback and domain name in my Twitter application using theark.info. What is the best way to make sure that I can use the same Twitter app for Oauth with www.theark.info, as I am currently getting an error:

Internal Server Error

In my DNS, I have CNAME wwwin my DNS that points totheark.info

Perhaps I need to manipulate the DOM with Express and Javacsript on request?

+5
source share
1

Twitter ( OAuth), . - http://domain.com http://www.domain.com, www.domain.com . DNS req.header :

app.get('/*', function(req, res, next) {
  if (req.headers.host.match(/^www/) !== null ) {
    res.redirect('http://' + req.headers.host.replace(/^www\./, '') + req.url);
  } else {
    next();     
  }
})

.

.js URL- :

passport.use(new TwitterStrategy({
    consumerKey: auth_keys.twitter.consumerKey,
    consumerSecret: auth_keys.twitter.consumerSecret,
    callbackURL: auth_keys.twitter.callbackURL
  },
  function(token, tokenSecret, profile, done) {
    process.nextTick(function () {
      User.twitterAuth({ profile: profile }, function (err, user) {
        return done(err, user);
      });
    });
  }
));

, callbackURL , Twitter. node , 127.0.0.1:3000 . dev production:

if (app.get('env') == 'development') {
  auth_keys = require('./lib/keys_dev');
} 
if (app.get('env') == 'production') {
  auth_keys = require('./lib/keys_live');
}
+2

All Articles