Cannot get all response headers from angular 2 using cors

I have an Angular 2 ( 2.1.2) client , ASP.NET Core as a backend with CORS enabled. The normal APIs (GET, POST, DELETE, ...) work fine, my problem is when I try to get the headers from the response; especially Content-Disposition. Here is a screenshot when I try to get the contents of a file using Ajax.

Request for Options

Get request

As you can see, there is a header with a name in the GET response headers Content-Disposition, but it is missing when I try to extract it from the Angular service http.

A quick note, I use only CORS in development.

+4
source share
2 answers

,

access-control-expose-headers: content-disposition

JavaScript.

+10

, ASP.NET Core Startup Configure:

app.UseCors(x =>
{
     x.WithExposedHeaders("Content-Disposition");
     // .. omitted
});
+2

Source: https://habr.com/ru/post/1660105/


All Articles