I am having trouble uploading a file using Angular. Every time I make the request, an error occurs stating: "Request has been blocked by CORS policy: Request header field content-disposition is not allowed by Access-Control-Allow-Headers in preflight response."
Below is the code I am using:
postXml(serviceName: string, data:any = {}){
const url = environment.apiUrl + "/" + serviceName;
let token = this.storageService.getWithoutAsync(AuthConstants.AUTH);
const header = new HttpHeaders({
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Authorization': `${token}`,
'Content-Disposition':"attachment; filename='file.xls'"
});
return this.http.post(url, data, { headers: header})
}