I'm using NodeJS with Express. How can I tell the difference between an ordinary browser request and an AJAX request? I know I could check the request headers but does Node/Exprsss expose this information?
Most frameworks set the X-Requested-With header to XMLHttpRequest, for which Express has a test:
X-Requested-With
XMLHttpRequest
app.get('/path', function(req, res) { var isAjaxRequest = req.xhr; ... });
1.4m articles
1.4m replys
5 comments
57.0k users