discord / discord-api-docs

Official Discord API Documentation
https://discord.com/developers/docs/intro
Other
5.9k stars 1.25k forks source link

Misleading API response for Cloudflare blocked requests #6473

Open hackermondev opened 11 months ago

hackermondev commented 11 months ago

Description

Discord recently changed their Cloudflare configuration to return a JSON error when the user is Cloudflare blocked instead of the HTML Cloudflare page.

Example response:

{
    "message": "internal network error",
    "code": 40333
}

This error is misleading, "internal network error" might make someone think Discord is having issues with their API.

Steps to Reproduce

Discord blocks Bot API requests with browser user agents, you can reproduce it with this command:

curl 'https://canary.discord.com/api/v9/channels/1051241605241262192/messages?limit=50' \
  -H 'authority: canary.discord.com' \
  -H 'authorization: Bot 1' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) discord/0.0.314 Chrome/108.0.5359.215 Electron/22.3.25 Safari/537.36' \
  --compressed

Expected Behavior

The API should return a more informative error like "Request blocked"

Current Behavior

{
    "message": "internal network error",
    "code": 40333
}

Screenshots/Videos

No response

Client and System Information

N/A

totallytavi commented 6 months ago

I can confirm this is still occurring. I recently encountered this when trying to send requests from Roblox through a proxy and blindly copied the User-Agent.

kiecooboi commented 4 months ago

me 2