This is my first StackOverflow input, so please be gentle :p
I'm doing a webapplication with the MEAN-stack, and I've ran into a problem that i cant seem to fix. Tried several solutions that i've found online, but nothing seems to work. I have this Node/Express backend, that contacts facebook, with a:
router.post('/login/facebook', passport.authenticate('facebook');
And then recieves a callback from facebook on:
router.get('/login/facebook/callback',
passport.authenticate('facebook', { failureRedirect: '/#' }),
function (req, res) {
console.log("in facebook return!");
console.log(req.user);
});
I can see in my console.log that the data I get back is what I expect! So far so good.. The problem is, that when i click my facebook login-button, that calls my satellizer facebook login:
$scope.authenticate = function(provider) {
$auth.authenticate(provider).then(function(res){
console.log(res.data);
});
};
.. I get this message in my chrome console:
XMLHttpRequest cannot load https://www.facebook.com/dialog/oauth?response_type=code&redirect_uri=..... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5000' is therefore not allowed access.
I guess theres something that i've overseen, but I cant figure out what.. When i Click the link it tryes to redirect to, I get my info printet in my console in the terminal. But I cant get redirected, as its not allowed, apparently..
Does anyone have an idea of what a solution could be? I've tried to put this into my server.app:
app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
next();
});
As I hoped I could get around the cross origin policy, but it didnt work either.
Any suggestions? :-)
Best regards!