CodeGenieApp / CodeGenieApp/serverless-express
Request path should not include the stage name with API Gateway V2 event source
- Lenguaje dominante
- JavaScript
- Estrellas
- 5.3k
- Forks
- 676
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
AWS always includes the stage name in the request path of API Gateway V2 events, even when using a custom domain and an ApiMapping.
**Without a custom domain**
* Invoke URL: `https://{apiId}.execute-api.{region}.amazonaws.com/{stageName}/foo`
* API Gateway V2 event's `rawPath`: `/{stageName}/foo`
* Path forwarded to the application: `/{stageName}/foo`
**With a custom domain / ApiMapping using an ApiMappingKey**
* Invoke URL: `https://{customDomain}/{ApiMappingKey}/foo`
* API Gateway V2 event's `rawPath`: `/{stageName}/foo`
* Path forwarded to the application: `/{stageName}/foo`
This means there is no reliable way to determine the real path entered in the user's address bar (stage name is not relevant when using a custom domain with ApiMapping, and ApiMappingKey is never forwarded in the event) :/ In the end, I think `serverless-express` should not include the stage name in the request path forwarded to `express` and allow to set a custom path prefix for all requests. It would make it possible to have a valid path for all deployment scenarios with a relatively minimal configuration setup.
There are multiple ways to do this, a reliable one being to trim the stage name from the path using `event.requestContext.stage`. You could also use `event.pathParameters.proxy` to set the path, but the user might not have used the `{proxy+}` proxy resource for his API.
Guía de contribución
Línea de trabajo
Comienza rastreando el manejo de eventos de API Gateway V2 que reenvía rawPath a Express, utilizando event.requestContext.stage y event.pathParameters.proxy como las alternativas descritas en el issue. Define cómo deben comportarse el recorte de stage y un prefijo de ruta configurable en implementaciones con dominio personalizado y sin dominio personalizado, y luego verifica la ruta de la solicitud reenviada para cada escenario.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- aws, express, javascript, node.js
- Área
- api, backend, cloud
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100