Angular/Node/Express/Passport Cross Domain Problems - Enable CORS Passport Facebook Authentication

前端 未结 3 970
甜味超标
甜味超标 2020-12-09 02:49

It\'s been two days and a million tries to enable CORS when trying to authenticate a user with Facebook using Passport in NodeJS/Express.

The error I get on Chrome i

3条回答
  •  庸人自扰
    2020-12-09 03:31

    I had also a problem with facebook login and cors but not with Passport in NodeJS/Express, my application is java(spring mvc)+ angular. I've managed to pass over the problem modifying my initial fb login function:

    $scope.loginWithFacebook = function () {
        $http({
            method: 'GET',
            url: 'auth/facebook',
            dataType: 'jsonp'
        }).success(function(data){
            console.log('loginWithFacebook success: ', data);
        }).error(function(data, status, headers, config) {
            console.log('loginWithFacebook error: ', data);
        });
    }
    

    with

    $scope.loginWithFacebook = function() {
        $window.location = $window.location.protocol + "//" + $window.location.host + $window.location.pathname + "auth/facebook";
    };
    

    Hope it helps!

提交回复
热议问题