script-lab icon indicating copy to clipboard operation
script-lab copied to clipboard

Office for Web: limited to port 3000

Open justmars opened this issue 2 years ago • 1 comments

Bug Report

  • Host: Word / Office for Web
  • OS: Mac
  • Browser: Edge
  • Environment: prod

Expected behavior:

While running a server on https://localhost:8000, I should be able to use

$("#run").click(() => tryCatch(run));

async function run() {
  Office.context.ui.displayDialogAsync(
        "https://localhost:8000/test",
        { height: 50, width: 30 },
        function (asyncResult) {
          console.log(JSON.stringify(asyncResult));
          if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            console.log(
              (asyncResult.error.code = ": " + asyncResult.error.message)
            );
          } else {
            console.log("Display dialog separate window")
          }
        }
      )
    }


/** Default helper for invoking an action and handling errors. */
async function tryCatch(callback) {
  try {
    await callback();
  } catch (error) {
    // Note: In a production add-in, you'd want to notify the user through your add-in's UI.
    console.error(error);
  }
}

Actual behavior:

I get the following result:

{"status":"failed","error":{"name":"Display Dialog Error","message":"The domain of the URL is not included in the AppDomains element in the manifest, and is not subdomain of source location.","code":12004}}
: The domain of the URL is not included in the AppDomains element in the manifest, and is not subdomain of source location.

Steps to Reproduce:

  1. Run server at localhost:8000
  2. Run office on the web with MS Word
  3. Install script lab
  4. Add code describe above to script lab
  5. Run script lab inputted code

See discussion here https://github.com/OfficeDev/office-js/issues/3586#issuecomment-1683297315

Am I correct that localhost / dialog links will always need to be port 3000 in script lab? When switching the server to 3000, everything seems to work as documented.

justmars avatar Aug 18 '23 09:08 justmars

You can see the list of AppDomains listed in the manifest here: https://github.com/OfficeDev/script-lab/blob/b98e6d773db6a2c175971a7d25b68d625c7e90e4/manifests/script-lab-react-prod.xml#L42C7-L42C7.

Only ports 3000 and 3200 are allowed for localhost.

akrantz avatar Oct 23 '23 15:10 akrantz

We no longer allow localhost in the appdomains.

If you need to use this advanced feature, I recommend creating a full Add-In

You can create and host your own Add-In on GitHub, for example see the Build Add-In you can sideload the manifest to try it out.

wandyezj avatar Apr 04 '24 19:04 wandyezj