问题
I have implemented node application with AWSServerlessExpress and deployed in Lambda function. but unable to point API Gateway to node routes. every time I'm getting 404 status.
var express = require('express')
, router = express.Router()
router.post('/es', function(request, response){
response.status(200).send("Lambda is triggered");
response.end()
})
router.get('/es/csv', function(request, response){
response.status(200).send("hello");
response.end()
})
module.exports = router;
How can I point API gateway directly to get Or Post route?
回答1:
After gone through the AWS documentation I have found a solution to my question. To forward the request from API Gateway to node routes in lambda we have to create a new proxy ({proxy+})resource in API gateway under this resource create any method(based on your requirement).
I found this answer here: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-create-api-as-simple-proxy
来源:https://stackoverflow.com/questions/49158423/is-it-possible-to-connect-api-gateway-with-node-routes-in-aws-lambda