cloudflare / node-cloudflare

Node.js API for Client API
https://cloudflare.github.io/node-cloudflare/
Other
335 stars 92 forks source link

403 error #99

Closed ririko5834 closed 7 months ago

ririko5834 commented 3 years ago

When I want to create DNS record or delete DNS record I am getting Response code 403 (Forbidden)

I am using cloudflare.dnsRecords.add() and cloudflare.dnsRecords.del() methods.

My API token perms: image

terinjokes commented 3 years ago

Do you have a code snippet that reproduces the problem?

ririko5834 commented 3 years ago

When I want to create or delete a DNS record, I get an error Response code 403 (Forbidden). When I view DNS records, it works and I don't get any error. I have an API token with permissions DNS:Edit and Zone:Edit. So what could be the problem?

ririko5834 commented 3 years ago

I know why it shows, when I called API endpoint with CURL, I got this error

{
    "result": null,
    "success": false,
    "errors": [{
        "code": 1038,
        "message": "You cannot use this API for domains with a .cf, .ga, .gq, .ml, or .tk TLD (top-level domain). To configure the DNS settings for this domain, use the Cloudflare Dashboard."
    }],
    "messages": []
}

The API wrapper's error catching should be improved, really high priority.

cixastra commented 3 years ago

+1 Having this error My code:

module.exports = async (cf_api_token, cf_zone, cf_record_id) => {
  var cf = require('cloudflare')({
    token: cf_api_token
  });

  return await cf.dnsRecords.del(cf_zone, cf_record_id); 
}
cixastra commented 3 years ago

Nevermind, it was because I was trying to use a freenom domain.