app.js: fix url port bug
authentication middleware: fix "first-time visitor" bug