Integrating the Sightengine image moderation API into a Node.js application led to encountering and solving various challenges.
Initially attempted to use native fetch and form-data in Node.js, which resulted in errors like ConnectTimeoutError and DNS ENOTFOUND.
Resolved DNS issues by bypassing the systemd-resolved resolver and pointing to public DNS.
Encountered limitations with Blob vs. streams while trying to stick with pure native APIs.
Opted for the final solution using form-data and node-fetch, providing a reliable approach in Node.js for file uploads with multipart requests.
The final code setup mirrors curl -F, streams the file efficiently, and ensures valid multipart requests.
In conclusion, by fixing DNS resolver, understanding FormData limitations in Undici, and resorting to form-data + node-fetch, a robust streaming multipart setup akin to curl -F can be achieved in Node.js.