> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/advanced/cors-ie9.md).

# CORS for IE9

Enable CORS for IE9 with XDomain library to load cross-origin resources in WebViewer. Follow steps to set up xdomain.js and proxy.html for seamless document viewing. The Apryse Web SDK streamlines sec

IE9 does not support cross origin requests so to allow WebViewer to load documents located on another domain you need to use the [XDomain library](https://github.com/jpillora/xdomain/).

{% hint style="warning" %}
**Please Note!**

We **only** recommend using XDomain if you need to use CORS and also support IE9. If you don't need to support IE9 then we recommend that you enable CORS on your server in the standard way.

See here for how to enable CORS without XDomain <https://enable-cors.org/server.html>.

If you need to support IE9 or you're really really sure that you need to use XDomain for another reason then continue on through this guide.
{% endhint %}

## Setting up

It is assumed that you have already set up a WebViewer project and have your documents hosted on another domain which you control.

1. Find xdomain.js in the WebViewer download under lib/ui-legacy/external/. Copy this file to the server where your documents are hosted.

{% hint style="warning" %}
Make sure to use this file instead of the one on the xdomain.js GitHub page as there have been modifications done to work with WebViewer.
{% endhint %}

1. Create an html file called proxy.html. The contents should look something like this:

{% tabs %}
{% tab title="HTML" %}
{% code lineNumbers="true" %}

```html
<!DOCTYPE HTML>
<script src="xdomain.js" master="http://www.mywebviewerserver.com"></script>
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
The src should point to the xdomain.js file you just uploaded and master should be set to the server where your viewer is located. This script sends the actual requests for the document so that they come from the same domain.
```

{% endcode %}
{% endtab %}
{% endtabs %}

1. Back in your viewer code, find the place where you call `new PDFTron.WebViewer({...})`. Add the option `xdomainProxyUrl` to the constructor so that it looks something like this:

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  xdomainProxyUrl: "http://mydocumentserver.com/proxy.html",
  initialDoc: "http://mydocumentserver.com/myxod.xod",
  ...
  ...
}, viewerElement);
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
The value of the property should be the URL of the proxy.html file you added previously.
{% endhint %}

1. If all of this has been done correctly WebViewer should now be able to load and view documents from the other domain.xdomain.js also allows multiple proxy URLs to be specified, so alternatively you could pass an object to WebViewer that specifies these URLs. See the [XDomain documentation](https://github.com/jpillora/xdomain#xdomainslavesslaves) for more details.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  xdomainProxyUrl: {
    "http://mydocumentserver.com": "/proxy.html",
    "http://myotherdocumentserver.com": "/proxy.html"
  },
  ...
}, viewerElement);
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/web/advanced/cors-ie9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
