Office-js addin with webapi. Failed to fetch

RaoulRSV 31 Reputation points

Windows 10 20H2, VS 2019 Community

Application contains one office-js addin (typescript) + one Webapi core (c#) in a container, both components communicating with a fetch function thanks to cors.
It works properly on my local computer.
I published both components on azure, the webapi component being derived as a container instance. I checked that the correct azure addin address was entered in the webapi startup module.

Now, each individual component works properly (proof with messages from the addin and with postman for the webapi) but fetch function raises errors (message = "failed to fetch").

Could someone tell me what I did miss ?

Thanks in advance.

A set of technologies in the .NET Framework for building web applications and XML web services.
4,281 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
909 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,136 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Bruce ( 59,021 Reputation points

    a fetch error only happens from a network or CORS error. you don't show the fetch code, so the error could be from after the fetch. for example:

      .then(response => response.json())
      .then(data => console.log(data));

    will throw an error if the response is not json (say a 500 error returning html). try:

      .then(response => {
           if (!response.ok) throw (`invalid response: ${response.status}`); 
           return response.json()
      .then(data => console.log(data));