Skip to content

Request headers are undefined in custom route handlers #1805

@zimeg

Description

@zimeg

From an internal report, it was noticed that req.headers === undefined in custom route handlers, which causes runtime errors when attempting to access attributes such as req.headers.host.

Reproducible in:

SDK version: @slack/bolt@3.13.0

Steps to reproduce:

  1. Initialize an App using the following:
const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  appToken: process.env.SLACK_APP_TOKEN,
  socketMode: true,
  customRoutes: [
    {
      method: "GET",
      path: "/health",
      handler: (req, res) => {
        res.writeHead(200)
        res.end(`Things are going just fine at ${req.headers.host}!`);;
      }
    },
  ],
});

(async () => {
  await app.start(3000);
  console.log('⚡️ Bolt app is running!');
})();
  1. Navigate to http://localhost:3000/health

Expected result:

The req.headers.host attribute to be set to localhost:3000 and the req.headers object to be defined with properties from the request.

Actual result:

The req.headers object is undefined.

Requirements

For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Metadata

Metadata

Assignees

Labels

bugM-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions