title: How to detect if the Office 365 account is on On Prem or Cloud by Office JS code?
body: <p>We have an Outlook (O365) add-in that runs on Calendar.</p>
  
  <p>We have used </p>
  
  <pre><code>office.context.mailbox.ewsurl
  </code></pre>
  
  <p>to detect the backend of an o365 account in our office js code. It returns the ews URL and if we find O365, office text in the URL, we would consider the account mailbox is on cloud. Accordingly, we run the Graph APIs related code for such accounts. </p>
  
  <p>However, it appears our thought process was wrong as the ews URL is customized for some of our customers and thus our detection goes wrong.</p>
  
  <p>How to detect the backend as On-Prem or Cloud? I know we can fire up the Graph APIs and handle the error code to decide the same on the failure, however, there are a lot of false positives here as well. We get quite a few subscription failures and some of them are not because of the backend being on-prem.</p>