API HTTP Gateway path rewrite question

0

Hi, I have API HTTP Gateway with ALB backends and I'm trying to migrate from

API Gateway -> internet-faced ALB (using HTTP URI integration) to API Gateway -> VPC link -> internal ALB.

My routes look like "/app1/{proxy+}". and in the first case, I used "https://app1.example.com/{proxy}", which rewrites "api.example.com/v1/app1/user/add" to "https://app1.example.com/user/add". Now I'd like to do the same rewrite with VPC link integration and I couldn't find a way to do that. Rewriting the path with "$request.path" giving me "/app1/user/add", and "$request.path.proxy+" giving me "/v1/app1/user/add".

1개 답변
1
수락된 답변

Hello,

Thank you for reaching out to us and sharing the detailed use-case.

The correct mapping parameter to overwrite the path would be as below :

/$request.path.proxy

Using "$request.path.proxy+" will give you "/v1/app1/user/add" as path as it is a catch all greedy path variable. This can be verified using context variable $context.path in access logging.

The correct way is using "$request.path.proxy" [1] which will give you the value "user/add" as path for the integration which is partially correct as it will throw 4xx error at the backend due to the missing initial "/".

Therefore, using "/$request.path.proxy+" will give you the proper value "/user/add" as path output which is suits your use-case. Please let me know if you still face any issues after implementing my above suggestion.

References: [1] https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-http.html

AWS
지원 엔지니어
답변함 2년 전
profile picture
전문가
검토됨 한 달 전
  • Many thanks! BTW, I think there is a typo: 'Therefore, using "/$request.path.proxy+" will give you the proper value "/user/add"' should be 'proxy', not 'proxy+'.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인