CORS Failure in Nodejs Expressjs with blob send

124 views Asked by At

We have recorded audio in browser using Angular 9 app and pass it to nodejs API with expressjs.

app.use(bodyParser.json());
app.use(cookieParser());
app.use(cors());

Whenever I send an audio record(blob) more than an 8min record. It starts requesting after 1min, I got CORS failed in XHR Transferred.

if the audio length is less than 8min, there is no error it requested API and saved the audio.

Please help me out with this.

Thanks

1

There are 1 answers

0
Satya Kalluri On

Let us say, your code had used CORS-npm and so is CORS-enabled. But, when the proxy (say Ngnix or Apache) failed to forward the request to underlying code for whatever reasons be it, say max-file-size exceeded, the response will usually be a 502-bad-gateway and headers will not have CORS-allowing-headers. That could be the reason why you see this message sporadically.
To begin with, you might want to play-around with the file-size setting and ensure files of any/acceptable length are permitted from the proxy into your codebase.

Here is how you would do it in NGinx:

http {
    ...
    client_max_body_size 100M;
}