API request CORS error within the Excel taskpane. Cookie does not show up in the request header

Nguyen, Phu [GIR] 0 Reputation points
2023-04-04T21:34:03.7266667+00:00

Hello, im running into a problem when i test my Excel add-ins within the Excel app. I was testing my add in through the Excel on browser and everything works fine. However, when we move to the Excel app and test the add-ins, we get all different type of CORS issue error. A few of those is "has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." and the "CORS preflight error". I also notice that there were no cookie being set when we make the request. I tried to add the options below to the header but still no luck. Is there something specific we need to do within the Excel app addins here?

const options = {
    headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept, Authorization"
    }
    withCredentials: true
}
Microsoft 365 and Office Development Office JavaScript API
Microsoft 365 and Office Development Other
Microsoft 365 and Office Excel For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Hua-MSFT 27,796 Reputation points
    2023-04-05T02:29:30.2466667+00:00

    Hi @Nguyen, Phu [GIR]

    I suggest you post new threads on other forums of the link: https://developer.microsoft.com/en-us/excel#excelcommunity.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.