Angularjs不使用Facebookauthentication策略拦截nodejs服务器提供的令牌

我是新的nodejs / angularjs和工作在我的第一个简单的Web应用程序。 我正在使用Passport和Node.js的Facebook身份validation策略。 成功的身份validation后,我想将jwt令牌返回给客户端的Angular应用程序。 我的服务器代码如下所示:

app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect : '/', session: false }), function(req, res){ res.set("x-access-token", req.user.JWTtoken); res.redirect("/#/main"); } ); 

我的客户端应用程序试图拦截响应以获取上面提供的jwt令牌。

 $httpProvider.interceptors.push(function($q) { return { 'request': function(config) { return config; }, 'response': function(response) { console.log(response.headers('x-access-token')); return response; } }; }); 

通过testing这个场景,我看不到响应头中的JWT标记。 有任何想法吗 ?

在服务器上设置标题时,不需要使用config属性。 改用response.headers ;

 $httpProvider.interceptors.push(function($q) { return { 'request': function(config) { return config; }, 'response': function(response) { console.log(response.headers('x-access-token')); return response; } }; });