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

Express middleware doesn't work with query strings #942

Open
asportnoy opened this issue Jun 23, 2023 · 0 comments
Open

Express middleware doesn't work with query strings #942

asportnoy opened this issue Jun 23, 2023 · 0 comments
Labels
status: help wanted requesting help from the community type: bug bug in the library

Comments

@asportnoy
Copy link
Contributor

Issue Summary

This was originally posted on StackOverflow and confirmed to be an issue by a Twilio employee.

The built-in Express middleware for webhook validation doesn't seem to work properly with query strings. According to the Twilio employee's response, the validateRequest will work for this, though I did not test that.

Steps to Reproduce

  1. Set up a webhook to a URL with a query string (I used a statusCallback URL)
  2. Handle that request with the webhook middleware
  3. Observe that the validation fails
  4. Remove the query string from the URL and verify that it works without the query string.

Code Snippet

const TwilioClient = Twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);

TwilioClient.messages.create({
    body: message,
    from: fromNumber,
    to: toNumber,
    statusCallback: 'https://example.com/webhook/twilio?id=12345',
});

// ...

router.post(
    '/twilio',
    twilio.webhook({
        authToken: process.env.TWILIO_AUTH_TOKEN,
        host: 'example.com',
        validate: true,
    }),
    async (req, res) => { /* ... */ },
);

Exception/Log

N/A but request returns a 403 due to the validation failing.

Technical details:

  • twilio-node version: v4.12.0
  • node version: v16.20.1
@AsabuHere AsabuHere added type: bug bug in the library status: help wanted requesting help from the community labels Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: bug bug in the library
Projects
None yet
Development

No branches or pull requests

2 participants