express - Problems calling Facebook with Angular $resource -
if use simple button href="users/facebook" in login form, facebook callback works fine.
i want change service function calls "users/facebook" not working. have:
login.html
<a href="" ng-click="facebooklogin()" class="btn btn-primary"><span class="fa fa-facebook"></span>
controllers.js
$scope.facebooklogin = function() { console.log('facebooklogin called'); authfactory.facebooklogin(); };
services.js
authfac.facebooklogin = function() { console.log('in services/facebooklogin'); $resource(baseurl + "users/facebook").get(function(){ }); };
routes/users.js
//not working router.get('/facebook', passport.authenticate('facebook'), function(req, res){ console.log('facebook called'); });
according console $resource call "https://localhost:3443/users/facebook" works ok router.get('/facebook) not working. can't see what's going wrong.
edit:
postman get https://localhost:3443/users/facebook
works can't understand why $resource(baseurl + "users/facebook").get(function()
isn't working.
i thought i'd taken care of cors adding following server file:
app.use(function(req, res, next) { res.setheader('access-control-allow-origin', '*'); res.setheader('access-control-allow-methods', 'get, post'); res.setheader('access-control-allow-headers', 'x-requested-with,content-type, authorization'); next(); });
but still issue in end fixed using:
window.location = window.location.protocol + '//' + window.location.host + '/users/facebook';
instead of:
$resource(baseurl + "users/facebook")
now facebookcallback function works.
Comments
Post a Comment