CodeGenieApp / CodeGenieApp/serverless-express
Request path should not include the stage name with API Gateway V2 event source
- Lingua principale
- JavaScript
- Stelle
- 5.3k
- Fork
- 676
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start by tracing the API Gateway V2 event handling that forwards rawPath to Express, using event.requestContext.stage and event.pathParameters.proxy as the alternatives described in the issue. Define how stage trimming and a configurable path prefix should behave across custom-domain and non-custom-domain deployments, then verify the forwarded request path for each scenario.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- aws, express, javascript, node.js
- Ambito
- api, backend, cloud
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100