Great question — answering as the UphillTech team:
Yes, your custom script is the "culprit". It happens in this section: headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36", "Content-Type": "application/json", }, You are sending a custom set of headers, basically User Agent and Content-Type . If you want to identify the Direct traffic, you need to add the Referer header with the relevant information.
Full answer by Luis Alberto Barandiaran: https://webmasters.stackexchange.com/a/144147 (CC BY-SA 4.0).
Need it done for your business? UphillTech.