I am attempting to retrieve a .xlsx file that is generated on the backend using Spring Boot. I am able to retrieve headers on the frontend, which include the content-disposition as shown below. However, I am unable to access the content disposition in the header.
As seen in the image below, Content disposition is not present in the headers; it is found in XHR response headers. Xhr response https://i.sstatic.net/aTL7V.png console.log https://i.sstatic.net/YcPZ3.png
I have enabled CORS policy on the backend,
public class WebSecurityConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**");
}
}
and attempted to get content-disposition on the client side
public static downloadFile(data: any, untilDestroyed$: DestroyService, toasterService?: ToastrService) {
const openInWindow = data.body.type === 'application/pdf';
console.log(data);
const dispositionHeader = data.headers.get('Content-Disposition'); // There lies the issue - value cannot be retrieved
const blob = new Blob([data.body], {type: data.body.type});
const url = window.URL.createObjectURL(blob);