$default route in API Stack

The API Stack documentation says that a default route can be created that will be matched if no other routes match

  routes: {
    "GET    /notes": "src/list.main",
    "POST   /notes": "src/create.main",
    "$default"     : "src/default.main",

I have implemented this per below, with all of my counterparties routes tested and working

        // Counterparties Routes
        "POST   /counterparties": "src/counterparties/create.main",
        "GET    /counterparties": "src/counterparties/list.main",
        "GET    /counterparties/{id}": "src/counterparties/get.main",
        "PUT    /counterparties/{id}": "src/counterparties/update.main",
        "DELETE /counterparties/{id}": "src/counterparties/delete.main",
        // Default route
        "$default": "src/default.main",

Whenever I invoke a specific /counterparties route, it appears that the default route is being invoked first - but the return value is not sent back to the client - before the actual route is invoked, and the expected results are passed back to the client.

Note: simple console.log() messages in the handler routines interspersed with the dev output in below

7247eaf8-96c5-45b9-9bf9-8c91a2bc26af REQUEST dev-beltway-api-apiLambdadefault7FDF9E47-t9fUvNdgzncY [src/default.main] invoked by API OPTIONS /counterparties
Message: The default route was invoked! <== console.log() message
7247eaf8-96c5-45b9-9bf9-8c91a2bc26af RESPONSE {"statusCode":200,"body":"{\"message\":\"This is the default handler, your route didn't match!\"}","headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":true}}
052edb13-9af8-4dd0-8941-9b9a670742dd REQUEST dev-beltway-api-apiLambdaGETcounterparties3E3FCB54-K9BagUK8LzLp [src/counterparties/list.main] invoked by API GET /counterparties
Data: { counterparty_type: 'supplier' }
SELECT counterparty_id, name, description FROM counterparties WHERE counterparty_type = :counterparty_type { counterparty_type: 'supplier' } <== console.log() message
052edb13-9af8-4dd0-8941-9b9a670742dd RESPONSE {"statusCode":200,"body":"[{\"counterparty_id\":\"ffac6330-b1d9-11ec-b81a-6da98ae8c111\",\"name\":\"All Rubber TMH Pty. Ltd.\",\"descri... 174 more characters","headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":true}}

What am I missing here? I’d assumed that the default route would only invoke it no other routes matched a request.

I assume your $default is being triggered by the HTTP request for OPTIONS /counterparties looking at your log output. You’ve not got a handler for that route so i’s triggering the default one?

Geez, you are absolutely correct, completely overlooked that, thanks!