From 351b12131e3ad863a1321166522aa90da54ce11c Mon Sep 17 00:00:00 2001 From: Foster Hangdaan Date: Mon, 4 Dec 2023 15:01:49 -0500 Subject: [PATCH] Fix incorrect API URL --- blog/posts/2023-12-02_make-your-own-ddns/index.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blog/posts/2023-12-02_make-your-own-ddns/index.md b/blog/posts/2023-12-02_make-your-own-ddns/index.md index af00d3f..7b3aaed 100644 --- a/blog/posts/2023-12-02_make-your-own-ddns/index.md +++ b/blog/posts/2023-12-02_make-your-own-ddns/index.md @@ -146,7 +146,11 @@ ## The Script // https://api.ipify.org const publicIpUrl = "https://ipme.fosterhangdaan.com"; -const goDaddyUrl = `https://api.godaddy.com/v1/domains/${domain}/records/A/@`; +const domainParts = domain.split("."); +const domainRoot = domainParts.slice(-2).join("."); +const domainName = domainParts.slice(0,-2).join(".") || "@"; + +const goDaddyUrl = `https://api.godaddy.com/v1/domains/${domainRoot}/records/A/${domainName}`; const goDaddyRequestHeaders = new Headers({ Authorization: `sso-key ${GODADDY_API_KEY}:${GODADDY_API_SECRET}`,