错误:无法在将标头发送到客户端后设置标头
我是Node.js的新手,我遇到了一些问题。
我使用的是Node.js 4.10和Express 2.4.3。
当我尝试访问http://127.0.0.1:8888/auth/facebook时,我将被重定向到http://127.0.0.1:8888/auth/facebook_callback。
然后我收到以下错误:
Error: Can't render headers after they are sent to the client. at ServerResponse.<anonymous> (http.js:573:11) at ServerResponse._renderHeaders (/home/eugene/public_html/all_things_node/projects/fb2/node_modules/connect/lib/patch.js:64:25) at ServerResponse.writeHead (http.js:813:20) at /home/eugene/public_html/all_things_node/projects/fb2/node_modules/connect-auth/lib/auth.strategies/facebook.js:28:15 at /home/eugene/public_html/all_things_node/projects/fb2/node_modules/connect-auth/lib/index.js:113:13 at next (/home/eugene/public_html/all_things_node/projects/fb2/node_modules/connect-auth/lib/strategyExecutor.js:45:39)var fbId= "XXX";var fbSecret= "XXXXXX";var fbCallbackAddress= "http://127.0.0.1:8888/auth/facebook_callback"var cookieSecret = "node";
// enter a random hash for securityvar express= require('express');var auth = require('connect-auth')var app = express.createServer();
app.configure(function(){
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({secret: cookieSecret}));
app.use(auth([
auth.Facebook({
appId : fbId,
appSecret: fbSecret,
callback: fbCallbackAddress,
scope: 'offline_access,email,user_about_me,user_activities,manage_pages,publish_stream',
failedUri: '/noauth'
})
]));
app.use(app.router);});app.get('/auth/facebook', function(req, res) {
req.authenticate("facebook", function(error, authenticated) {
if (authenticated) {
res.redirect("/great");
console.log("ok cool.");
console.log(res['req']['session']);
}我可以知道我的代码有什么问题吗?
红糖糍粑
慕雪6442864
暮色呼如
随时随地看视频慕课网APP