[Resolved] Can't get server route to log to console

I’m implementing a webhook for the Stripe API but am unable to log anything from the route - not really sure what I’m doing wrong…

Router.route( '/webhook/stripe', function () {
  var event_json = this.request.body;

  console.log('hello');
  console.log(event_json);

  this.response.statusCode = 200;
  this.response.end('OK');
}, { where: 'server' });

I’m using Ultrahook to handle receiving the request on localhost, and the request comes in fine (and sends a 200 response), but I can’t get anything to log in the meteor console. Have tried a few things now - anything obvious?

Log:

=> Meteor server restarted
=> Client modified – refreshing (x9)

(not even an undefined)

Oh, um, turns out the route isn’t working (or maybe it is), which was a bit unexpected. So two new issues:

  1. Why does Meteor send a 200 response when there’s no matching route (surely should be a 404, or other 400 response code?)
  2. Any idea why that route wouldn’t work?

Messing with syntax I rounded back to how my other routes are presented:

Router.route("/webhook/stripe", {
  name: 'StripeHook',
  where: 'server',
  action: function () {
    var event_json = this.request.body;

    console.log('hello');

    this.response.statusCode = 200;
    this.response.end('OK');
  }
});

Visiting the route in my browser (http://localhost:3000/webhook/stripe) gives me:

Oops, looks like there’s no route on the client or the server for url: http://localhost:3000/webhook/stripe

Ok, not great. Removing the where: 'server', from the equation the page attempts to render (albeit with errors relating to this.response). Not entirely unexpected, as now it’s not a server route I should be able to visit it, but the error clearly states, “there’s no route on the client or the server”.

So to be honest iron router/meteor seems as confused as I am. So is the route on the client or the server or not? How do I log from it? What’s wrong with the above syntax?

I’m going to leave this here for prosperity and humiliation purposes, but for what it’s worth the reason the server route refused to work is that my existing router file is in the /client directory :sleepy: Having since moved it to /lib/router.js the endpoint is now working!

So actually the error from Meteor was correct, it kind of didn’t exist on the client or server (but did exist on the client when the server option was removed).

(But it’s still interesting that meteor sends a 200 response on a 404…)