问题
I am working on an outlook plugin and I want to send the attachements from an email read item to my backend.
I am trying to use the method getAttachementContentAsync for each attached file, but it fails. Here is the error message:
Uncaught (in promise) TypeError: Failed to fetch
Access to fetch at '' (redirected from '') from origin 'https://outlook.live.com' has been blocked by CORS policy: 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.
and my code:
const attachements = Office.context.mailbox.item.attachments.map(attachement => {
let rObj = {};
rObj.id = attachement.id;
rObj.name = attachement.name;
return rObj;
});
attachements.forEach(attachement => {
Office.context.mailbox.item.getAttachmentContentAsync(attachement.id, result => console.log(result));
});
};```
I have found a ticket on github that might be related: https://github.com/OfficeDev/office-js/issues/644
Is there a way to set the headers to that request manually or is there another solution to this issue?
来源:https://stackoverflow.com/questions/60758519/office-addin-getattachementcontentasync-failed-to-load-cors-issues