मैं निम्नलिखित कोड है:CORS त्रुटि
app.js:
var passport = require('passport')
, FacebookStrategy = require('passport-facebook').Strategy
, ...
passport.serializeUser(function(user, done) {
console.log('serializing user')
done(null, user);
})
passport.deserializeUser(function(obj, done) {
console.log('deserializeUser')
done(null, obj)
})
passport.use(new FacebookStrategy({
clientID: FBAPP.id,
clientSecret: FBAPP.secret,
callbackURL:
"http://www.mylocal.com:3000/auth/facebook/callback"
},
function(accessToken, refreshToken, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function() {
return done(null, profile)
})
}
))
app.get('/auth/facebook', passport.authenticate('facebook',
{ scope: ['email, user_likes, user_photos, publish_actions'] }))
app.get('/auth/facebook/callback',
passport.authenticate('facebook', {
successRedirect: '/loginsuccess', failureRedirect : '/loginfail' }))
app.get('loginsuccess', function(req, res) {
console.log('Login success')
res.send(200, 'ok')
})
app.get('/loginfail', function(req, res) {
console.log('Login error')
res.send(401, 'error')
})
कोणीय हिस्सा:
factory('FacebookFactory', ['$http', '$q', function($http, $q) {
var get = function() {
var deferred = $q.defer();
$http({method: 'GET', url: '/auth/facebook'}).
success(function(data, status, headers, config) {
deferred.resolve(data);
}).
error(function(data, status, headers, config) {
deferred.reject(data);
});
return deferred.promise;
};
return {
get: get
};
}])
मैं हमेशा इस त्रुटि मिलती है और कई प्रयास किया था लेकिन कोई सफलता नहीं।
XMLHttpRequest cannot load https://www.facebook.com/dialog/oauth?
response_type=code&redirect_uri=http%…
user_likes%2C%20user_photos%2C%20publish_actions&client_id=xxxxxxxxxxx.
No 'Access-Control-Allow-Origin' header
is present on the requested resource. Origin '[basic
links]http://www.mylocal.com:3000' is therefore
not allowed access.
कोई भी कोई विचार? मैंने पूरी तरह से कोणीय में कोशिश की लेकिन फिर यह सफारी में काम नहीं करता है लेकिन क्रोम और एफएफ में यह पूरी तरह से काम करता है।
www.mylocal.com:3000 = स्थानीय होस्ट: 3000
यहां एक ही समस्या है! क्या आपने समाधान ढूंढने का प्रबंधन किया? –
वास्तव में नहीं। फेसबुक पक्ष पर एक नए ऐप के साथ स्क्रैच से पुनरारंभ करने के अलावा। यह काम करता था लेकिन तुलना में कोई फर्क नहीं पड़ता था। –
क्या आपको शायद $ http.jsonp() का उपयोग करने की आवश्यकता है? केवल अनुमान है। –