Rest API 500 Error: Origin does not match the domain set on license key

Which product are you using?

PDF.js Express Plus

PDF.js Express Version

Build: “Ny80LzIwMjR8MzMxOTBmNGM5YQ==”
Core version: “8.7.5”
Full API: false
UI version: “8.7.0”
WebViewer Server: false
webviewer.min.js: “8.7.5”

Detailed description of issue
When trying to use the Rest API to either extract or set annotations on a PDF stored in AWS S3 I am getting error code 26, “Origin does not match the domain set on license key”. This is working fine in development on localhost, and only fails when in production.

Expected behaviour
The domain on the key is set to “docuwrx.com”, and the origin of the request is “https://app001.docuwrx.com:8050

Does your issue happen with every document, or just one?
All documents

Link to document
Not available

Code snippet

const extractAnnotations = async () => {
  const data = new FormData();
  data.append(
    "file",
    props.file.url,
  );
  data.append("license", PDFJS_REST_API_KEY);

  const options = {
    method: "POST",
    body: data,
  };

  const response = await fetch(
    "https://api.pdfjs.express/xfdf/extract",
    options,
  )
  .then((response) => response.json())
  .catch((error) => console.error(error));

  const { xfdf } = response;
  await instance.docViewer.getAnnotationManager().importAnnotations(xfdf);
};

If I change the API key domain to “https://app001.docuwrx.com:8050” instead of “docuwrx.com” it does work. I’m guessing that having the port number in the origin of the request is causing this to fail.

Hi there,

Using the TLD without the port should work for subdomains but it is possible that the port number in the origin request is causing the issue.

Please see this forum post for more details:

Best regards,
Kevin Kim