The article discusses the challenges faced while trying to mirror a curl -F snippet in pure Node.js for streamlining image moderation API uploads.
Using undici and the form-data package initially led to ConnectTimeoutError and DNS ENOTFOUND issues, despite curl working fine.
A workaround involved bypassing the resolver systemd-resolved and pointing to public DNS to resolve the API host.
After restarting systemd-resolved, both nslookup and the Node.js code managed to resolve the API host.
Attempts were made to rely on pure native APIs, but FormData.append in Undici only accepted string, Buffer, or Blob contents, resulting in errors.
The most reliable approach chosen in Node.js involved using a specific method to mirror curl -F, stream the file to avoid a memory hit, and generate valid multipart requests.