Search code examples
sharepointms-officeoffice365office365-appsoutlook-web-addins

Office Mail App - First time open issue - Files hosted in O365 SP-Hosted App


I have builded a Office Mail App. By default when creating a Office App in Visual Studio, you will get a project for the Manifest File and a Web Project for all HTML5/css/js files. These Web Project files could be hosted on a Web Server or in Azure etc. But I prefer to host these files in SharePoint as a SharePoint-Hosted App, because we don't have a Web Server of Azure enviroment currently available.

The first time when I open the Office App, I'm getting an error 'App Error: Something went wrong and we couldn't start this app'. When I press the retry button, everything is working. And also after that the Office App keeps working, until I close the browser. After closing and reopening the browser, I have the issue again the first time I open the Office App.

I've looked with Fiddler and it seems that it has something to do with the first time authentication against SharePoint (where the files are hosted). After the authentication (and receiving the cookie) there is no problem anymore.

Is there any way to overcome this issue?

I could deploy the app in the O365 Public Website with Anonymous Access. But I don't want that, because this website isn't Online.


Solution

  • Unfortunately, as long as you are hosting your Mail App in a Sharepoint site, there is a chance that you will hit this issue. Currently, there is no way to overcome this issue.

    Background

    In the Apps for Outlook framework, there is a maximum amount of time allowed between the point in time when the app is opened and the the time Office.js is loaded inside the app. Once that maximum amount of time is reached without Office.js being loaded, it times out and shows the error UX that you mention in your question.

    In vast majority of the scenarios, the allotted maximum is more than enough time to load all the resources including Office.js. However, with Sharepoint, there is a certain amount of time that it takes to do auth redirects, which increases latency and makes it more likely that you will hit this timeout.