How to get wopi discovery in the host page

1.3k views Asked by At

I'm working on an Office integration for the web using WOPI and trying to get the WOPI action from discovery.

I know the dogfood/testing endpoint from where I can get the discovery. But I couldn't directly get it in my web app due to cross-origin issue as it is in a different domain.

Am I supposed to store the discovery in API and serve it to the web app?

2

There are 2 answers

0
JSAddict On BEST ANSWER

Answering for the readers.

I was checking with Microsoft Senior Program Manager, he confirmed that WOPI discovery is meant to be a server-server thing. We need to fetch the WOPI discovery in the API side and keep it in cache until the proof key validation fails.

2
rocky On

I guess you are talking about these two discovery files. It seems that they have the Access-Control-Allow-Origin headers set to *, so that shouldn't be the problem.

I quickly tried this and it seems to work fine:

fetch('https://ffc-onenote.officeapps.live.com/hosting/discovery')
  .then(response => response.text())
  .then(str => (new window.DOMParser()).parseFromString(str, "text/xml"))
  .then(data => console.log(data))
  .catch(function(error) {
    console.log(error);
  });

You can run it here: https://jsfiddle.net/rockyintel/ycrw293n/13/

Maybe one more question, is your domain added to the WOPI domain allow list?