Is it possible to connect API gateway with node routes in AWS lambda?

谁说胖子不能爱 提交于 2019-12-24 01:58:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!