botpress / v12

Botpress OSS – v12
https://v12.botpress.com
GNU Affero General Public License v3.0
69 stars 83 forks source link

Teams webhook returns 404 when running botpress on a (not empty) root path #1777

Open gpdeltedesco opened 9 months ago

gpdeltedesco commented 9 months ago

Description

When running botpress on path (e.g. EXTERNAL_URL=http://localhost:3000/some_path), messaging endpoint for teams fails with 404 (e.g. POST http://localhost:3000/some_path/api/v1/messaging/webhooks/<bot-id>/teams)

To reproduce

  1. Run botpress with a not empty root path:

    docker run --rm --name botpress --publish 3000:3000 --env "EXTERNAL_URL=http://localhost:3000/botpress" botpress/server:v12_31_0
  2. Navigate to http://localhost:3000/botpress and create an admin

  3. Create an empty bot named empty_bot, and configure teams channel:

    ...
     "messaging": {
       "channels": {
         "teams": {
           "enabled": true,
           "appId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
           "appPassword": "01234567890.1234567890.123456789.abcde.."
         }
       }
     }
  4. Try to post to http://localhost:3000/botpress/api/v1/messaging/webhooks/empty_bot/teams

    curl -vvv --request POST http://localhost:3000/botpress/api/v1/messaging/webhooks/empty_bot/teams
    *   Trying 127.0.0.1:3000...
    * Connected to localhost (127.0.0.1) port 3000 (#0)
    > POST /botpress/api/v1/messaging/webhooks/empty_bot/teams HTTP/1.1
    > Host: localhost:3000
    > User-Agent: curl/7.88.1
    > Accept: */*
    > 
    < HTTP/1.1 404 Not Found
    < X-Powered-By: Express
    < content-security-policy: default-src 'none'
    < x-content-type-options: nosniff
    < content-type: text/html; charset=utf-8
    < content-length: 173
    < date: Fri, 06 Oct 2023 01:20:59 GMT
    < connection: close
    < Vary: Accept-Encoding
    < 
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Error</title>
    </head>
    <body>
    <pre>Cannot POST /botpress/webhooks/empty_bot/teams</pre>
    </body>
    </html>
    * Closing connection 0

Expected behavior

Botpress should be able to resolve the given URL (in this case, should return 400 BAD REQUEST). To ilustrate, repeat the example but with EXTERNAL_URL=http://localhost:3000 and executing a POST to http://localhost:3000/api/v1/messaging/webhooks/empty_bot/teams

Screenshots n/a

Environment (please complete the following information):

Additional context n/a