由于之前博客为了输入方便一直放在根域名,现在需要将字体部署到子域名下,为了干净整洁些需要将之前的DNS删除。
并且不再用vercel部署,采用cloudflare
进入cloudflare,添加一个编辑区域DNS的API Token,并记录下Token。
点击进入域名的概述,Zone ID在右侧一列中
创建一个powershell脚本(.ps1),并替换API_TOKEN
和ZONE_ID
$API_TOKEN = "<API_TOKEN>"
$ZONE_ID = "<ZONE_ID>"
$baseUrl = "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records"
$headers = @{
'Authorization' = "Bearer $API_TOKEN"
'Content-Type' = "application/json"
}
$listUrl = $baseUrl + '?per_page=500'
Write-Host $listUrl
$records = Invoke-RestMethod -Uri $listUrl -Method 'GET' -Headers $headers
$records = $records | Select-Object -ExpandProperty result
foreach ($record in $records) {
Write-Host "Deleting $($record.name) that points to $($record.content)"
$deleteUrl = $baseUrl + '/' + $record.id
Invoke-RestMethod -Uri $deleteUrl -Method 'DELETE' -Headers $headers
Write-Host $deleteUrl
}
右键文件以powershell运行。由于我有700多条记录,执行两次即可