jeremydaly / lambda-api

Lightweight web framework for your serverless applications
https://serverless-api.com
MIT License
1.42k stars 126 forks source link

"error": "Method not allowed" #182

Closed raja-vcomply closed 5 months ago

raja-vcomply commented 3 years ago

When i am hitting the route its returning "method not allowed"

raja-vcomply commented 3 years ago

@jthomerson @jeremydaly help me pls

jeremydaly commented 3 years ago

Hey @raja-vcomply!

Can you post some sample code?

codyfyi commented 3 years ago

@raja-vcomply - I just ran into this too. I was using API Gateway V2, but it appears lambda-api won't support the v2.0 event payload format until 0.11 per this comment:

v0.11 supports Payload V2 and should be available shortly.

Originally posted by @jeremydaly in https://github.com/jeremydaly/lambda-api/issues/174#issuecomment-808725167

If this sounds like your case, you can force the API Gateway V2 to use the v1.0 payload format in the settings. I also noticed the new $default route did not work with lambda-api, and had to configure / and /{proxy+} routes instead.

mattwen-amzn commented 3 years ago

If I understand the situation correctly @codyfyi, I believe it does support v2.0 events. Your code should be this.

const app = api.default({version: 'v2.0'});