Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Axios expose response headers: Content-Disposition

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

like image 628
pranay-91 Avatar asked May 11 '17 10:05

pranay-91


People also ask

What is content-disposition in response header?

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.

What is Access Control expose headers?

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.

What is content-disposition inline?

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.

What is content-disposition attachment filename?

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.


1 Answers

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.

like image 169
E.Egiazarov Avatar answered Sep 18 '22 15:09

E.Egiazarov