CodeGenieApp / CodeGenieApp/serverless-express
Request path should not include the stage name with API Gateway V2 event source
- 主要言語
- JavaScript
- スター
- 5.3k
- フォーク
- 676
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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.
コントリビューションガイド
調査の方向性
まず、rawPath を Express に転送する API Gateway V2 イベント処理を追跡し、issue で説明されている代替手段として event.requestContext.stage と event.pathParameters.proxy を使用します。カスタムドメインおよび非カスタムドメインのデプロイメント全体で、stage のトリミングと設定可能なパスプレフィックスがどのように動作すべきかを定義し、その後、各シナリオで転送されるリクエストパスを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- aws, express, javascript, node.js
- 領域
- api, backend, cloud
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100