ExpressJS – throw er Unhandled error event

I created expressjs application using the following commands: express -e folderName npm install ejs –save npm install When I run the application with: node app.js, I have the following errors: events.js:72 throw er; // Unhandled ‘error’ event ^ Error: listen EADDRINUSE at errnoException (net.js:884:11) at Server._listen2 (net.js:1022:14) at listen (net.js:1044:10) at Server.listen (net.js:1110:5) at Object.<anonymous> … Read more

Proxy with express.js

To avoid same-domain AJAX issues, I want my node.js web server to forward all requests from URL /api/BLABLA to another server, for example other_domain.com:3000/BLABLA, and return to user the same thing that this remote server returned, transparently. All other URLs (beside /api/*) are to be served directly, no proxying. How do I achieve this with … Read more

how to get request path with express req object

I’m using express + node.js and I have a req object, the request in the browser is /account but when I log req.path I get “https://stackoverflow.com/” — not ‘/account’. //auth required or redirect app.use(‘/account’, function(req, res, next) { console.log(req.path); if ( !req.session.user ) { res.redirect(‘/login?ref=”+req.path); } else { next(); } }); req.path is / when … Read more