我正在嘗試將我的應用程序的facebook登錄集成到nodejs,使用passport-facebook模塊的angularjs中。XMLHttpRequest無法加載https://www.facebook.com/dialog/oauth?response_type=code&redirect_uri=
我可以G642.44各級Facebook驗證沒有angularjs,但是當我使用的角度http.get('/auth/facebook')
我收到以下錯誤
XMLHttpRequest cannot load https://www.facebook.com/dialog/oauth?response_type=code&redirect_uri=http%…%2Flocalhost%3A1439%2Fauth%2Ffacebook%2Fcallback&client_id=xxxxxxxx. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:1439' is therefore not allowed access.
app.js:153 err
下面是我的角碼
var headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Content-Type': 'text/html'
};
$scope.fblogin=function(){
// $window.location.href='/auth/facebook';
$http({
url:'/auth/facebook',
method:'GET',
headers: headers
}).success(function(data){
console.log(data);
}).error(function(){
console.log('err');
});
};
pp.config(['$routeProvider','$httpProvider',
function($routeProvider,$httpProvider) {
$httpProvider.defaults.useXDomain = true;
$httpProvider.defaults.headers.common = 'Content-Type: application/json';
delete $httpProvider.defaults.headers.common['X-Requested-With'];
的NodeJS
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
**注:**我試過改變$ http.get()的多個頭部更改
/AUTH/Facebook是發起url和/ AUTH /實/回調是在標題輸入反應回調 這個/ AUTH /實/回調是重定向URI – Prithvi
@Prithvi - 但是,錯誤消息說:'https:// www.facebook.com/dialog/oauth' – jfriend00