tencentcloud-edgeone-migration-nodejs-v2
Version:
tencentcloud cdn config copy to edgeone
44 lines (38 loc) • 1.23 kB
JavaScript
const { t } = require("../../i18n/trans");
const genLog = require("../../logGenerator");
function ErrorPage(domain, domainConfig, ruleTransferLog) {
const keyConfig = domainConfig.ErrorPage;
if (!keyConfig || !keyConfig.PageRules || !keyConfig.PageRules.length || keyConfig.Switch !== 'on') {
ruleTransferLog.push({
config: t('自定义错误页面配置(ErrorPage)'),
result: t('未配置'),
detail: ''
});
genLog.defaultLog(`${t('自定义错误页面配置(ErrorPage)')}${t('未配置')}`)
return null;
}
const { PageRules } = keyConfig;
// 剔除公益404页面
const filterPageRules = PageRules.filter(rule => {
return rule.RedirectCode !== 404;
});
ruleTransferLog.push({
config: t('自定义错误页面配置(ErrorPage)'),
result: t('成功'),
detail: ''
});
genLog.successLog(`${t('自定义错误页面配置(ErrorPage)')}${t('成功')}`)
return {
'CodeAction': {
'Action': 'ErrorPage',
'Parameters': filterPageRules.map(rule => {
return {
'StatusCode': rule.StatusCode,
'Name': 'RedirectUrl',
'Values': [rule.RedirectUrl]
};
})
}
};
}
module.exports = ErrorPage;