juanjoDiaz / serverless-middleware

Serverless plugin to allow middleware handlers configured directly in serverless.yaml
MIT License
18 stars 11 forks source link

"pre" configuration doesn't work for http handlers #31

Closed ii-igku closed 3 years ago

ii-igku commented 3 years ago

we're on Serverless 2.5 and trying to configure the middleware plugin. here is the test configuration

custom:
  middleware:
    pre:
      - api/helpers/version-manager-2.checkVersion

functions:
  test-middleware:
    handler: api/http/discover/testmw.handler
    description: GET test-middleware
    events:
      - http:
          path: test-middleware
          method: get

and it works fine when we call a function like this:

serverless invoke local --function test-middleware

but when we're trying to start sls offline and call the same function using postman GET http://localhost:3000/test-middleware



the middleware function is not being called.

what are we doing wrong?
ii-igku commented 3 years ago

actually never mind - it looks like it's an issue with Serverless Offline plugin, not with the Middleware. after we deployed the configuration we can see the pre-function is being called.

it would be great to have sls offline work as well though, I may try to create an improvement request there...