github-webhookprobot

Github Probot create-probot-app: 'Cannot POST /' (404) response to webhook request


Testing out the npx create-probot-app; tried with each of the starters and the same problem exists.

I create, build, and run the app, and then configure and install the app on github, I am able to receive webhook events but I'm seeing my local app respond with a 404.

smee receives the event

error: Error: cannot POST / (404)
ERROR (server): Not Found
    Error: Not Found
        at Request.callback (/Users/X/Projects/Y/compiler/githubapp/x-bot/node_modules/superagent/lib/node/index.js:884:15)
        at IncomingMessage.<anonymous> (/Users/X/Projects/Y/compiler/githubapp/x-bot/node_modules/superagent/lib/node/index.js:1127:20)
        at IncomingMessage.emit (events.js:326:22)
        at IncomingMessage.EventEmitter.emit (domain.js:483:12)
        at endReadableNT (_stream_readable.js:1241:12)
        at processTicksAndRejections (internal/process/task_queues.js:84:21)
status: 404

My index.ts:

export = (app: Probot) => {
  app.on("issues.opened", async (context) => {
    const issueComment = context.issue({
      body: "Thanks for opening this issue!",
    });
    await context.octokit.issues.createComment(issueComment);
  });
  // For more information on building apps:
  // https://probot.github.io/docs/

  // To get your app running against GitHub, see:
  // https://probot.github.io/docs/development/
};

I've checked that my environment variables appear to be setup correctly in .env

In sum, github is sending a webhook, smee is receiving it, but my local app is responding with 404: cannot post /

Not able to get the example app to process webhook events due to what appears to be a routing issue. Anyone encountered this before?


Solution

  • Make sure you don't have any other applications running on Port 3000. Create React App uses 3000 by default and can cause the error you are describing.