我正在使用 AWS API Gateway 及其 HTTP 代理。
我需要通过 CloudFront-Viewer-Country
头到我的端点。我尝试遵循以下问题中概述的相同设置
Access headers in AWS API Gateway using HTTP Proxy?
我在端点服务器上收到以下 header 。
Array
(
[host] => example.com
[Accept] => application/json
[User-Agent] => AmazonAPIGateway_c8752844lh
[x-amzn-apigateway-api-id] => c8752844lh
[X-Amzn-Trace-Id] => Root=1-59bd7a5e-003ef07b3c4c3680299801f1
[X-Forwarded-For] => xx.xxx.xx.xxx
[X-Forwarded-Port] => 443
[X-Forwarded-Proto] => https
[Connection] => keep-alive
)
然而,
CloudFront-Viewer-Country
不在其中。如果我使用 lambda 函数而不是 HTTP 代理,我可以看到更多的 header (包括 CloudFront-Viewer-Country
)。谁能告诉我如何使用 HTTP 代理访问端点上所需的 header ?
最佳答案
对于您想要 header 的资源和方法,转到方法请求 → HTTP 请求 header → 添加 header 并将名称设置为 CloudFront-Viewer-Country
.单击带圆圈的复选标记进行添加。这将 header 暴露给执行流程的其余部分。
然后,在集成请求 → HTTP header → 添加 header 。
将名称设置为 CloudFront-Viewer-Country
并设置映射自 method.request.header.CloudFront-Viewer-Country
并单击带圆圈的复选标记进行添加。这将获取公开的 header 并将其添加到转发到后端的请求中。
部署 API。
关于amazon-web-services - 使用 HTTP 代理访问 AWS API Gateway 中的 cloudfront-viewer-country header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46257648/