# P5.js loadStrings() error: Fetch API cannot load file

**URL:** https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842
**Category:** Beginners
**Created:** [September 13, 2020, 4:32pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842 "2020-09-13T16:32:40Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Tsloa](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@Tsloa](https://discourse.processing.org/u/Tsloa)
#### Post date: [September 13, 2020, 4:32pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/1 "2020-09-13T16:32:40Z")

</div>

I am trying to use LoadStrings() in a p5.js and in the console, I get the error “p5.js:60518 Fetch API cannot load file:[FILENAME].txt. URL scheme must be “http” or “https” for CORS request.”  
I googled it and people said that it only works on firefox but it doesn’t even work on firefox for me

here is the code in question:

var track = [];

function setup() {  
loadStrings(“track.txt”, getText)  
}

function getText(data) {  
track = data;  
}

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [September 13, 2020, 4:55pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/2 "2020-09-13T16:55:18Z")

</div>

> [@Tsloa](#):
>
> I googled it and people said that it only works on Firefox but it doesn’t even work on Firefox for me.

> <https://github.com/berinhard/pyp5js/issues/72#issuecomment-513395187>
>
> Since \[this last update\](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/…Errors/CORSRequestNotHttp?utm\_source=devtools&utm\_medium=firefox-cors-errors&utm\_campaign=default), firefox now is forcing CORS even for local files. Because of that, now we may need an http server to serve the sketch's \`index.html\`

---

<div class="post-metadata">

### Author: ![Tsloa](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@Tsloa](https://discourse.processing.org/u/Tsloa)
#### Post date: [September 13, 2020, 5:13pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/3 "2020-09-13T17:13:07Z")

</div>

do you have any suggestions for how i can fix this  
id rather not have to host a local server backause im actually working on a commision and it would be a bit of bother to have to get them to host a locl server aswell and set the file up.

---

<div class="post-metadata">

### Author: ![Tsloa](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@Tsloa](https://discourse.processing.org/u/Tsloa)
#### Post date: [September 13, 2020, 5:14pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/4 "2020-09-13T17:14:55Z")

</div>

@GoToLoop

sorry i didnt reply to you directly

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [September 13, 2020, 5:25pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/5 "2020-09-13T17:25:13Z")

</div>

> [@Tsloa](#):
>
> Do you have any suggestions for how I can fix this?

My posted link above got a workaround for Firefox. 🦊

For more workarounds see the link below: 🔗

> [@Maximum size of a method in Processing](https://discourse.processing.org/t/maximum-size-of-a-method-in-processing/17136/29):
>
> Another workaround: [Chrome-allow-file-access-from-file.com](http://Chrome-allow-file-access-from-file.com) A more complete solution: More solutions: [GitHub.com/processing/p5.js/wiki/Local-server](http://GitHub.com/processing/p5.js/wiki/Local-server)

---

<div class="post-metadata">

### Author: ![Tsloa](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@Tsloa](https://discourse.processing.org/u/Tsloa)
#### Post date: [September 13, 2020, 6:30pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/6 "2020-09-13T18:30:38Z")

</div>

hello man i tried the cmd workaround specified on [Chrome-allow-file-access-from-file.com](http://Chrome-allow-file-access-from-file.com)  
it didnt work  
any other suggestions, i have to get this done by wednesday and i cant work on it untuill i get this fixed

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [September 13, 2020, 6:36pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/7 "2020-09-13T18:36:53Z")

</div>

Anything relying w/ the new Fetch API doesn’t work w/ that Chrome workaround.

Fetch API is compatible w/ the `file://` scheme on Firefox though.

---

<div class="post-metadata">

### Author: ![Tsloa](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@Tsloa](https://discourse.processing.org/u/Tsloa)
#### Post date: [September 13, 2020, 7:20pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/8 "2020-09-13T19:20:34Z")

</div>

so that cmd solution will work for firefox?

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [September 14, 2020, 12:09am UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/9 "2020-09-14T00:09:00Z")

</div>

As the name of the site implies: [Chrome-allow-file-access-from-file.com](http://Chrome-allow-file-access-from-file.com)  
That workaround is for Chrome-based browsers only.

For Firefox-based 1s you just use the trick described on the 1st link I’ve posted:

> **[Reason: CORS request not HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp#Local_File_Security_in_Firefox_68)**
>
> CORS requests may only use the HTTPS URL scheme, but the URL specified by the request is of a different type. This often occurs if the URL specifies a local file, using a file:/// URL.

---

<div class="post-metadata">

### Author: ![Tsloa](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@Tsloa](https://discourse.processing.org/u/Tsloa)
#### Post date: [September 14, 2020, 2:13pm UTC](https://discourse.processing.org/t/p5-js-loadstrings-error-fetch-api-cannot-load-file/23842/10 "2020-09-14T14:13:49Z")

</div>

ive got it working on firefox, thank you man.  
very annoying that it doesnt work by default
