32

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. headers

Is there any way i can access that value?

axios version: 0.15.2 Environment: node v6.9.4, chrome 54, windows 7

Brown Bear
  • 19,655
  • 10
  • 58
  • 76
pranay-91
  • 323
  • 1
  • 3
  • 9

1 Answers1

51

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.

E.Egiazarov
  • 851
  • 9
  • 6
  • 1
    I am using a django backend with a vue frontend, and setting the header in the django side fixed it for me too. – rodurico Dec 04 '19 at 19:24