amazon-web-services - 为什么 lambda 函数在测试中不输出我的标头?
问题描述
我创建 lambda 函数:
exports.handler = (event, context, callback) => {
const { response } = event.Records[0].cf;
response.headers["x-my-header"] = [{ value: "test" }];
return callback(null, response);
};
我点击保存并点击“测试”。
但是我看不到x-my-header
。为什么?我在这里想念什么?
解决方案
我已经运行了您的 LAmbda 并在使用cloudfront-modify-response-header
.
{
"status": "200",
"statusDescription": "OK",
"headers": {
"vary": [
{
"key": "Vary",
"value": "*"
}
],
"last-modified": [
{
"key": "Last-Modified",
"value": "2016-11-25"
}
],
"x-amz-meta-last-modified": [
{
"key": "X-Amz-Meta-Last-Modified",
"value": "2016-01-01"
}
],
"x-my-header": [
{
"value": "test"
}
]
}
}
看起来它运行正常,我相信测试和测试事件之间的区别存在混淆。测试事件本身是 Lambda 函数的输入,当您测试函数时,您将查看输出以查看基于此事件输入的响应,如下面的屏幕截图所示。
推荐阅读
- python - 从 pandas 的列标题中删除前缀(或后缀)子字符串
- javascript - 从外部 HTML 表中获取数据到数组
- user-interface - 最后添加的Jhipster关系
- swift - 如何在 Process() 中包含命令修饰符?
- node.js - 如何使用 process.env 和在 NGINX 中运行的构建 node.js 应用程序
- c++ - 如何使用友元函数中的嵌套类?
- java - 如何将嵌套的 JsonObjects 作为 JSON 字符串遍历?
- php - 使用explode方法从数据库中提取日期时间
- c# - 如何在没有 IdentityServer 或 OAuth 的情况下配置 JWT STS
- firefox - Firefox 会停止在 Stackoverflow 或 github 中显示带有代码的页面,而 chromium 不会