Why does Passport.js give me a middleware error?
You still need to app.use(app.router)
after Passport. Otherwise, your route will run before any Passport code, and that's why you see the error. This should work:
app.use(express.static(__dirname + '/public'));
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);