AWS API Gateway:传递引荐来源网址 [英] AWS API Gateway: Pass Referrer URL

查看:92
本文介绍了AWS API Gateway:传递引荐来源网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对API网关的请求是否有可能将引荐来源网址传递给Lambda?例如,我很想让我的lambda函数知道请求是否来自域名"good.com"和"bad.com".

Is it possible for requests to the API-Gateway to pass the referrer URL to Lambda? For example, I'd love to let my lambda functions know if a request comes from the domain "good.com" vs. "bad.com".

我熟悉受支持的$ context变量,我知道其中没有引荐来源网址.我想知道是否还有另一种方式.如果有可能,我需要采取什么步骤?

I'm familiar with the list of supported $context Variables and I know a referrer url is not in there. I'm wondering if there is another way. If it is possible, what steps do I need to take?

推荐答案

此处是操作方法.

  1. 事实证明,该映射模板允许您映射 HTTP标头 ,而不仅仅是支持的变量列表在文档中.

包含引荐来源网址域的HTTP标头称为来源".包含引用页面URL的标题称为引用".

The HTTP header that contains the referrer domain is called "Origin". The header that contains the referer page URL is called "Referer".

因此,例如,您可以将其放在映射模板中,它将获取关联的标头信息:

So, for example, you can put this in your mapping template and it will grab the associated header information:

{
"origin" : "$input.params('origin')",
"referer" : "$input.params('referer')"
}

Origin抓取example.com.引荐来源抓住example.com/pagename

Origin grabs example.com. Referer grabs example.com/pagename

这篇关于AWS API Gateway:传递引荐来源网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆