Here are two solutions:
1、setting the time out in the web server ,such as in nginx config file。
proxy_connect_timeout 15m;
2、use queue in NodeJS,when the API is running ,you can add the task to queue , and return to browser immediately。the task was run in the queue background