使用 Lambda@edge 的 Cloudfront 错误页面 - 设置的正确方法?

问题描述

在 Lambda@Edge 上为 Cloudfront distribution 设置自定义错误页面的正确方法是什么?

Cloudfront Error Page

我正在尝试设置与上述内容相同的内容。试过了,但它不起作用:

'use strict';

exports.handler = (event,context,callback) => {
const response = event.Records[0].cf.response;

if (response.status == 403 || response.status == 404) {
    response.status = 200;
    response.statusDescription = 'OK';
    response.body = '';
    
    response.headers['location'] = [{ key: 'Location',value: '/index.html' }];
}

callback(null,response);
};

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)