0

Having a really strange problem here.

I have a Restify / Node app. For debug purposes I catch 'request' and 'after' events:

server.on('request',function(req, res){
    console.log('## REQUEST');
    console.log('## '+req.url);
})

server.on('after',function (request, response, route, error) {
    console.log('## REQUEST -- AFTER');
    console.log(route);
});

Now the strange part. In an angular app I make a single call to one of the endpoints, and in the network tab of Chrome I can only see one request.

This is writen to the console:

App 14193 stdout: ## REQUEST
App 14193 stdout: ## /api/projects/5512c6bb046da5793001b70e
App 14193 stdout: ## REQUEST
App 14193 stdout: ## /api/projects/5512c6bb046da5793001b70e

So two request came in and got processed.

Now if I right click on the network line in Chrome and get the request in cURL and run it, it only gets called once (I have another debug line in the actual method that's run), but it does not trigger the 'request' or 'after' events.

I starting to go a bit crazy here :-). Does anyone have any idea of what might be going on?

Ricardo Gomes
  • 1,268
  • 2
  • 15
  • 35
  • What happens if you use curl directly from the command line? I just created a bare bones restify app with your 'request' and 'after' functions and it is working fine with curl on the command line. I have just about zero experience with Angular so I haven't tried that. – HeadCode Jul 29 '15 at 00:38
  • I'm using curl from the command line, but I'm not writing it, I get the command from Chrome's Network tab, and the request is fulfilled but those events don't trigger – Ricardo Gomes Jul 30 '15 at 10:32
  • 1
    It's pretty hard to say based on your description and the amount of code given. I suggest creating a bare bones restify app with your 'request' and 'after' handlers and see if that works first. – HeadCode Jul 31 '15 at 05:04
  • Possible duplicate of [Requesting a website by client side script = Cross Side Scripting Hack. But requesting a website by server side script is not a hack! Why?](http://stackoverflow.com/questions/3023050/requesting-a-website-by-client-side-script-cross-side-scripting-hack-but-requ) – Paul Sweatte Oct 21 '15 at 14:50

0 Answers0