Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't access Content-Disposition in axios

I have a React JS application where I send a GET request with axios. In the browser, in the Response Headers section, when I send the request I get Content-Disposition: attachment;filename="image123.pdf", but when I try to get this in React, I don't get any field with this name. So when I try to access the response.headers['content-disposition'], I don't get anything.

Is it possible to read this header key using React JS using axios?

like image 808
Asking Avatar asked Nov 23 '25 21:11

Asking


1 Answers

You must ensure that appropriate access has been granted from the server side for this matter through CORS. You can perform a quick comparison with the following piece of code to make sure that there is no issue for server-side access to this specific matter. check it in server:

res.header('Access-Control-Expose-Headers', 'Content-Disposition');

The next step for you is to make sure that you are sending these two items from the client side to the server.

set in header (client-side):

responseType: 'blob',
withCredentials: true,
like image 155
Amirali Hatami Avatar answered Nov 25 '25 09:11

Amirali Hatami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!