How to implement a login with Node.js (behind nginx) and AngularJS -


at moment try build site public , private area. use node.js server-side. node.js provides data via rest web services front-end , handle login. data stored in mongodb. front-end built angularjs. @ moment use nginx static files , rest calls (/api/…) , login (/login) pass node.js.

this current file structure:

www |-- public |     |-- css |     |-- img |     |-- js |     |   +-- templates |     |         +-- login.html  |     | |     +-- index.html | |-- private |     |-- css |     |-- img |     |-- js |     |   +-- templates |     |         +-- someprivatestuff.html  |     | |     +-- index.html 

in node.js use passport authentication.

app.post('/login', passport.authenticate('local'), function(req, res) {     res.redirect('http://localhost/private'); }); 

if user authed successfully, redirected /private. problem file structure above, served nginx. because static files. how can prevent people accessing private-area directly typing url /private (or other files in directory). should use node.js static files handle access files? read use nginx in front of node.js common approach.

if understand correctly you're looking for?

http://wiki.nginx.org/xsendfile


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -