Skip to content

Commit 2acb32d

Browse files
authored
Merge pull request #28 from P1X3/patch-1
Update index.js
2 parents b0ea3b7 + 3f9723e commit 2acb32d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function handleRequest(request) {
4949
*/
5050
async function informAPI(url, name, token) {
5151
// Parse Url
52-
const hostname = url.searchParams.get("hostname");
52+
const hostnames = url.searchParams.get("hostname").split(",");
5353
// Get the IP address. This can accept two query parameters, this will
5454
// use the "ip" query parameter if it is set, otherwise falling back to "myip".
5555
const ip = url.searchParams.get("ip") || url.searchParams.get("myip");
@@ -60,8 +60,10 @@ async function informAPI(url, name, token) {
6060
});
6161

6262
const zone = await cloudflare.findZone(name);
63-
const record = await cloudflare.findRecord(zone, hostname);
64-
const result = await cloudflare.updateRecord(record, ip);
63+
for (const hostname of hostnames) {
64+
const record = await cloudflare.findRecord(zone, hostname);
65+
const result = await cloudflare.updateRecord(record, ip);
66+
}
6567

6668
// Only returns this response when no exception is thrown.
6769
return new Response(`good`, {

0 commit comments

Comments
 (0)