CodeGenieApp / serverless-express

Run Express and other Node.js frameworks on AWS Serverless technologies such as Lambda, API Gateway, Lambda@Edge, and more.
https://codegenie.codes
Apache License 2.0
5.08k stars 658 forks source link

Incompatibility with AWS API Gateway #662

Open gustavolaranjeira opened 6 months ago

gustavolaranjeira commented 6 months ago

Vendia's serverless-express package does not work as expected with AWS API Gateway, it only returns a blank screen instead the swagger screen. This issue is forcing us to use the serverless-http package.

To reproduce the error, you basically have to: 1) Create an AWS Lambda function* with a simple project containing express, serverless-http or vendia and swagger; 2) Configure the AWS API Gateway to consume the Lambda function created in the step 1.

*Node versions tried: 14/16/18/20 BTW. Using AWS Lambda function URLs Vendia's serverless-express package works pretty fine with swagger.

Example of a simple project containing express, serverless-http or vendia and swagger:


const express = require('express')
const serverless = require('serverless-http')
const swaggerUI = require('swagger-ui-express')

const app = express()
app.use(
  '/swagger',
  swaggerUI.serve,
  swaggerUI.setup(null, {
    swaggerOptions: {
      url: "https://petstore.swagger.io/v2/swagger.json"
    }
  })
)

module.exports.handler = serverless(app)
brettstack commented 6 months ago

Thanks for the report! I'll take a look and update you.

murilo09 commented 6 months ago

Same problem here, I solved it using serverless-http.

brettstack commented 6 months ago

Did this only just start happening? Is it only an issue when using Swagger UI?

murilo09 commented 6 months ago

Did this only just start happening? Is it only an issue when using Swagger UI?

I had never used serverless-express with swagger-ui-express and API Gateway but when I tried it (monday) I had this problem with the blank screen on the swagger route.

gustavolaranjeira commented 6 months ago

Did this only just start happening? Is it only an issue when using Swagger UI?

If you use AWS Lambda function URLs with Vendia's serverless-express package works pretty fine with Swagger but if use with AWS API Gateway It returns a blank screen on the doc page.

thetumper commented 6 months ago

Related to https://github.com/brettstack/serverless-express/issues/400?

gustavolaranjeira commented 6 months ago

Related to #400?

No, it's not!

H4ad commented 5 months ago

I already got an error like this and it was caused by low lambda concurrency, below 5 the Swagger will not render, maybe is not related but try to check the concurrency.