Express.js使用passport-facebook - TypeError:对象302没有方法' indexOf'

时间:2014-05-20 13:53:27

标签: express passport.js passport-facebook

我已经有一个快速项目已经运行,我只是试图通过使用护照进行连接来通过facebook进行身份验证,我基本上已经从github页面复制了这个示例:

https://github.com/jaredhanson/passport-facebook

但每当我尝试在我的应用中转到'/ auth / facebook'网址时,我都会收到以下错误:

TypeError: Object 302 has no method 'indexOf'
    at ServerResponse.res.redirect (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/response.js:546:13)
    at Strategy.strategy.redirect (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport/lib/middleware/authenticate.js:294:15)
    at Strategy.OAuth2Strategy.authenticate (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport-facebook/node_modules/passport-oauth2/lib/strategy.js:227:10)
    at Strategy.authenticate (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport-facebook/lib/strategy.js:84:41)
    at attempt (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport/lib/middleware/authenticate.js:337:16)
    at authenticate (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport/lib/middleware/authenticate.js:338:7)
    at callbacks (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:171:11)
    at param (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:145:11)
    at pass (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:152:5)
    at Router._dispatch (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:179:5)

1 个答案:

答案 0 :(得分:1)

它可能与旧版本的快递不兼容;你可以尝试更新到express@3.5.x; 3.6及以上版本弃用了某些方法,重构可能不值得。

如果它是全局包,请尝试npm install express@3.5.xnpm install express@3.5.x -g。确保也更新package.json文件。