Vis*_*han 2 amazon-cloudfront aws-lambda-edge
我正在使用lambda @ edge使用Cloudfront重定向我的网站。
我已将版本化的lambda arn附加到其所有4个事件的云前端缓存行为中。
当我到达我的cloudfront端点时,它说
502 ERROR
The request could not be satisfied.
The Lambda function returned invalid json: The json output must be an object type.
Run Code Online (Sandbox Code Playgroud)
当我查看我的lambda日志/调用指标时,我什么都没有看到。
这可能是什么原因?
我尽力找到解决办法,以防止未触发我的lambda?
Lambda @ Edge和CloudFront有一些常见的“陷阱”。你需要:
arn:aws:lambda:us-east-1:572007530218:function:gofaas-WebAuthFunction:45这与保存代码更改并从“监视”选项卡跳转到日志的“常规” Lambda Web控制台流程不同。
我错过了在 lambda 代码中的标题下添加区域。
由于 lambda@edge 在边缘位置运行,我们需要动态提及该区域,以便它在最近的边缘位置运行时知道在哪里写入日志。
'x-lae-region': [ { key: 'x-lae-region', value: process.env.AWS_REGION } ]
const response = {
status: '302',
statusDescription: 'Found',
headers: {
location: [{
key: 'Location',
value: 'http://<destinationdomainname>/goto/hello.html',
}],
'x-lae-region': [ { key: 'x-lae-region', value: process.env.AWS_REGION } ],
},
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1619 次 |
| 最近记录: |