1

My XHR request sent default Cache-Control header. However, the server side requires no such headers.So, what should I do to remove such default headers in a XHR request? I've already try to do like this:

xhr.setRequestHeader("Cache-Control", null);
xhr.setRequestHeader("Cache-Control", "");
xhr.setRequestHeader("Cache-Control", undefined);

But none of them works.

Aaron Liu
  • 13
  • 3

1 Answers1

0

I know it's probaly too late. I had the same problem you had. I couldn't find a way around it, my solution was to use fetch

fetch( 'someurl/api/send',
   {
    method: 'POST',
    body: formData,
    headers:{
    Authorization: authToken
    }
    }) 

formData is

formData = new FormData()
formData.append('file', someFile)

This automatically set the appropriate headers.

Tepexic
  • 21
  • 4