I'm trying to get the 'Content-Disposition' Header of a request from api call by axios like this:
axios.get('Group/GetGroupObjectives', {
params: { periodId, isPreliminary },
responseType: 'arraybuffer',
})
.then((response) => {
if (response) {
response.request.getResponseHeader('Content-Disposition');
} else {
dispatch(docDownloadFailed());
}
})
When i get the header throws this error "Refused to get unsafe header "Content-Disposition""
This problem is caused by Cors in the api, but i get all the headers needed for get the header correctly in the response header:
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:*
Access-Control-Request-Headers:*
Cache-Control:no-cache
Content-Disposition:attachment; filename="sample.xlsx"
Content-Length:7965
Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Date:Fri, 26 Jan 2018 14:35:38 GMT
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/10.0
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?RDpcVGVhbV9Tb2Zhc2FcRXh0cmFuZXRcRXh
How do I get the response header correctly with axios call?