Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request headers are undefined in custom route handlers #1805

Closed
zimeg opened this issue Apr 18, 2023 · 0 comments · Fixed by #1806
Closed

Request headers are undefined in custom route handlers #1805

zimeg opened this issue Apr 18, 2023 · 0 comments · Fixed by #1806
Assignees
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
Milestone

Comments

@zimeg
Copy link
Member

zimeg commented Apr 18, 2023

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.

@zimeg zimeg added the bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented label Apr 18, 2023
@zimeg zimeg added this to the 3.13.1 milestone Apr 18, 2023
@zimeg zimeg self-assigned this Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant