Office addin getAttachementContentAsync failed to load CORS issues

我怕爱的太早我们不能终老 提交于 2021-01-29 19:39:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!