I'm working on a node.js application, using Angular.js, passport and connect-ensure-login.
Only on refresh (F5), does the redirect in ensureLoggedIn seem to work and I get to the login page, otherwise I think the routeProvider for the one-page app just takes over for normal click and I get to localhost:3000/users still with the 500 error from '/api/users'.
How can I get connect-ensure-login (ensureLoggedIn) working for both direct path and click-through?
app.get('/users', ensureLoggedIn('/login'))
For APIs, I'm using
app.get('/api/users',
passport.authenticate('bearer'),
...
routeProvider snippet for the application:
.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/home.html'
})
...
References: