Comments (10)
It seems to have been an issue with supporting both api gateway 1 and 2.
When I last tested it version was sent as 1.0 in api gateway 1 (now it is missing - this caused my validation to fail).
I have published version 0.2.3 with a fix, if no version exists in the payload the version defaults to 1.0.
from aws-lambda-http-server.
I can't find when but I think the payload of the api gateway v2 request changed since I last tested it.
In any case please update again and your httpAPI endpoint should now work
from aws-lambda-http-server.
How is the function invoked? The event payload should have httpMethod
set when invoked by http.
from aws-lambda-http-server.
Once deployed I just hit the url directly on the browser. That should automatically set the method to GET right?
from aws-lambda-http-server.
Could you post your lambda code?
from aws-lambda-http-server.
Sure!
server.js
const express = require('express');
const app = express();
app.get('/', (req, res) => {
return res.json({ message: 'Hello world!'});
})
app.get('/hello', (req, res) => {
return res.send('world');
});
app.listen(3000, () =>
console.log('Example app listening on port 3000!'),
);
and lambda.js
exports.proxy = require('aws-lambda-http-server')
require('./server.js')
serverless.yml
service: xpresslamb
provider:
name: aws
runtime: nodejs12.x
region: eu-west-1
functions:
proxy:
handler: lambda.proxy
events:
- http:
path: /{proxy+}
method: any
- http:
path: ''
method: any
from aws-lambda-http-server.
@shivkanthb could you please check it now works for you with the latest version?
from aws-lambda-http-server.
Hey @JamesKyburz, Thank you for the quick fix! Did an npm update and sls deploy
and its working great now for the REST API.
Deployed another one to use the HTTP api with the following serverless.yml file
service: xpresslambhttp
provider:
name: aws
runtime: nodejs12.x
region: eu-west-1
functions:
proxy:
handler: lambda.proxy
events:
- httpApi: "*"
But I get the following error
2020-12-14T06:52:36.005Z 54cc8395-bc9f-4553-a426-e6499f6086fb ERROR TypeError: Cannot read property 'toLowerCase' of undefined
at Route._handles_method (/var/task/node_modules/express/lib/router/route.js:63:21)
at next (/var/task/node_modules/express/lib/router/index.js:244:30)
at expressInit (/var/task/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/var/task/node_modules/express/lib/router/index.js:317:13)
at /var/task/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/var/task/node_modules/express/lib/router/index.js:335:12)
at next (/var/task/node_modules/express/lib/router/index.js:275:10)
at query (/var/task/node_modules/express/lib/middleware/query.js:45:5)
at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)
2020-12-14T06:52:36.005Z 54cc8395-bc9f-4553-a426-e6499f6086fb ERROR TypeError: Cannot read property 'toLowerCase' of undefined at Route._handles_method (/var/task/node_modules/express/lib/router/route.js:63:21) at next (/var/task/node_modules/express/lib/router/index.js:244:30) at expressInit (/var/task/node_modules/express/lib/middleware/init.js:40:5) at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/var/task/node_modules/express/lib/router/index.js:317:13) at /var/task/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/var/task/node_modules/express/lib/router/index.js:335:12) at next (/var/task/node_modules/express/lib/router/index.js:275:10) at query (/var/task/node_modules/express/lib/middleware/query.js:45:5) at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)
Im invoking again by just hitting the endpoint on the browser! Anything I'm missing here?
from aws-lambda-http-server.
Thanks James! Updated and works now! Really appreciate it :)
from aws-lambda-http-server.
Great stufff! Thanks for identifying the problem.
from aws-lambda-http-server.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-lambda-http-server.