I was able to set request headers to expose Content-Disposition by adding: "Access-Control-Expose-Headers": "Content-Disposition"
I can see the response but the response object does not include Content-Disposition. Click here for detail screenshot
Is there any way i can access that value?
axios version: 0.15.2 Environment: node v6.9.4, chrome 54, windows 7
In a regular HTTP response, the Content-Disposition response header is a header indicating if the content is expected to be displayed inline in the browser, that is, as a Web page or as part of a Web page, or as an attachment, that is downloaded and saved locally.
The Access-Control-Expose-Headers response header allows a server to indicate which response headers should be made available to scripts running in the browser, in response to a cross-origin request. Only the CORS-safelisted response headers are exposed by default.
Content-Disposition takes one of two values, `inline' and `attachment'. 'Inline' indicates that the entity should be immediately displayed to the user, whereas `attachment' means that the user should take additional action to view the entity.
Content-Disposition: attachment; filename=FILENAME. The filename parameter can be used to suggest a name for the file into which the resource is downloaded by the browser.
In my case I had to enable CORS-related feature on the server side:
Access-Control-Expose-Headers: Content-Disposition
This allows javascript on the browser side to read this header.
In case of node.js + express + cors on the server side it may looks like this:
app.use(cors({
origin: 'http://localhost:8080',
credentials: true,
exposedHeaders: ['Content-Disposition']
}))
So I can see "content-disposition" among the headers, returned by Axios.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With