I`m facing an issue where after I create binaries from pdf files uploads and them save them on the a DocumentReference attachment I cannot load the pdfs previews on my custom app because it returns CORS error.
Here follows the code snipet on how the pdfs binaries are being created and saved:
----
const binaries = await Promise.all(files.map(file =>
medplum.createBinary({
data: file,
contentType: file.type
})
));
const document: DocumentReference = {
resourceType: 'DocumentReference',
status: 'current',
...
date: moment(formData.reportedDate).utc().format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
content: binaries.map(binary => ({
attachment: {
contentType: binary.contentType,
url: binary.url
}
})),
..
};
----
After this I`m loading the saved attachments blob with:
await medplum.download(selectedDocument.content[selectedAttachmentIndex].attachment.url);
And then I`m receiving this error:
Access to fetch at 'https://storage.medplum.com/binary/..' from origin **'localhost or our custom production domain**' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Is there a way to workaround this considering that we have a custom web app running on top of Medplum Hosted client?
Obs: For image files this is working fine.