English 中文(简体)
为什么护照给我一个中度的错误?
原标题:Why does Passport.js give me a middleware error?

我在尝试这里描述的工作

https://github.com/jaredhanson/passport/issues/14

app.use(passport.initialize());
app.use(passport.session());  
app.use(app.router);
app.use(express.static(__dirname +  /public ));

工作报酬

app.use(app.router);
app.use(express.static(__dirname +  /public ));
app.use(passport.initialize());
app.use(passport.session()); 

gives

DEBUG: Error: passport.initialize() middleware not in use
    at IncomingMessage.<anonymous> (/.../node_modules/passport/lib/passport/http/request.js:30:30)
    at Context.<anonymous> (/.../node_modules/passport/lib/passport/middleware/authenticate.js:92:11)
    at Context.<anonymous> (/.../core/node_modules/passport/lib/passport/context/http/actions.js:21:25)
    at Strategy.success (native)
最佳回答

护照后仍然需要<代码>app.use(app.router)。 否则,您的路线将沿用任何护照编码,因此,你会发现错误。 这一工作应当:

app.use(express.static(__dirname +  /public ));
app.use(passport.initialize());
app.use(passport.session()); 
app.use(app.router);
问题回答

Might help someone, I had the same issue. My app configure looked like this. This caused the error.

app.configure(function() {
  ....
app.use(app.router);    
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static(path.join(__dirname,  public )));

});

I had to reorder as below for it to work.

app.configure(function() {
  ....
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);    
app.use(express.static(path.join(__dirname,  public )));

});

我的工作是:

app.use(passport.initialize());
app.use(passport.session());

页: 1





相关问题
How to make Sequelize use singular table names

I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names? Thanks.

What is Node.js? [closed]

I don t fully get what Node.js is all about. Maybe it s because I am mainly a web based business application developer. What is it and what is the use of it? My understanding so far is that: The ...

Clientside going serverside with node.js

I`ve been looking for a serverside language for some time, and python got my attention somewhat. But as I already know and love javascript, I now want learn to code on the server with js and node.js. ...

Can I use jQuery with Node.js?

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...

热门标签