# Cross origin requests error

**URL:** <https://forum.anaconda.com/t/cross-origin-requests-error/20337>\
**Category:** PyScript\
**Created:** [May 2, 2022, 6:14am UTC](https://forum.anaconda.com/t/cross-origin-requests-error/20337 "2022-05-02T06:14:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwitiderrick](https://dub1.discourse-cdn.com/anaconda/user_avatar/forum.anaconda.com/mwitiderrick/32/1193_2.png) [@mwitiderrick](https://forum.anaconda.com/u/mwitiderrick)\
**Post date:** [May 2, 2022, 6:14am UTC](https://forum.anaconda.com/t/cross-origin-requests-error/20337/1 "2022-05-02T06:14:52Z")

</div>

Loading an external Python script gives this error

```auto
   <py-script src="index.py" output="mpl"> </py-script>

```

```auto
Access to fetch at 'file:///Users/derrickmwiti/PycharmProjects/Layer-videos/pyscript/index.py' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
base.ts:67 GET file:///Users/derrickmwiti/PycharmProjects/Layer-videos/pyscript/index.py net::ERR_FAILED
getSourceFromFile @ base.ts:67
await in getSourceFromFile (async)
evaluate @ base.ts:109
await in evaluate (async)
initializePyodide @ App.svelte:38
load (async)
listen @ index.mjs:412
listen_dev @ index.mjs:2015
mount @ App.svelte:53
mount_component @ index.mjs:1799
init @ index.mjs:1893
App @ App.svelte:48
(anonymous) @ main.ts:21
(anonymous) @ main.ts:23
pyodide.asm.js:14 Element.write: TypeError: Failed to fetch --> True
pyodide.asm.js:14 APPENDING: True ==> mpl --> TypeError: Failed to fetch
pyscript.ts:134 Collecting nodes...

```

---

<div class="post-metadata">

**Author:** ![MARTIN\_DURANT](https://dub1.discourse-cdn.com/anaconda/user_avatar/forum.anaconda.com/martin_durant/32/67_2.png) [@MARTIN\_DURANT](https://forum.anaconda.com/u/MARTIN_DURANT)\
**Post date:** [May 3, 2022, 1:49pm UTC](https://forum.anaconda.com/t/cross-origin-requests-error/20337/2 "2022-05-03T13:49:30Z")

</div>

How are you serving your HTML file? Since double-clicking it in a file browser?

---

<div class="post-metadata">

**Author:** ![mwitiderrick](https://dub1.discourse-cdn.com/anaconda/user_avatar/forum.anaconda.com/mwitiderrick/32/1193_2.png) [@mwitiderrick](https://forum.anaconda.com/u/mwitiderrick)\
**Post date:** [May 3, 2022, 5:55pm UTC](https://forum.anaconda.com/t/cross-origin-requests-error/20337/3 "2022-05-03T17:55:17Z")

</div>

Right-click and open in Chrome. I get this error

```auto
JsException(TypeError: Failed to fetch)

```

---

<div class="post-metadata">

**Author:** ![MARTIN\_DURANT](https://dub1.discourse-cdn.com/anaconda/user_avatar/forum.anaconda.com/martin_durant/32/67_2.png) [@MARTIN\_DURANT](https://forum.anaconda.com/u/MARTIN_DURANT)\
**Post date:** [May 3, 2022, 6:13pm UTC](https://forum.anaconda.com/t/cross-origin-requests-error/20337/4 "2022-05-03T18:13:40Z")

</div>

[javascript - Allow Google Chrome to use XMLHttpRequest to load a URL from a local file - Stack Overflow](https://stackoverflow.com/questions/4819060/allow-google-chrome-to-use-xmlhttprequest-to-load-a-url-from-a-local-file) provides information. This is a security feature of Chrome, you need to make extra files available via HTTP, and to have those servers CORS-accept from your page.

You could do this simply with python’s `http` module. “But pyscript needs no server” you may say; well it’s a little complicated. We will probably provide tooling to bundle python source files into a single download at some point; but for now use a development server.
