sandbox.js:1 bring API cannot pack file:///C:/Users/Lizzi/Desktop/novice%20to%20ninja/todos/luigi.json. URL scheme must be "http" or "https" for CORS request

I"m new to aynchronouse programming but I have actually read up on CORS solutions and also tried things like getting a chrome extension and disabling web security because that my google chrome but it tho doesn"t work.

fetch("todos/luigi.json").then((response)=> console.log("resolved",response);).catch((err)=> console.log("rejected", err););


You are watching: Url scheme must be "http" or "https" for cors request.

javascript promise fetch
re-publishing
improve this concern
monitor
edited Sep 27 "19 in ~ 5:37

*

Gayan S. Muthukumarana
1,20611 yellow badge88 silver badges2525 bronze badges
inquiry Sep 27 "19 at 5:16
*

Elizabeth EssienElizabeth Essien
19311 yellow badge11 silver badge66 bronze badges
6
| present 1
much more comment

1 answer 1


energetic earliest Votes
24
You need to be serving your index.html locally or have your site organized on a live server somewhere for the having API to job-related properly. The records need to be offered using the http or https protocols.

If you simply clicked on her index.html from your record explorer than your browser is grabbing those files directly from your document system. This is why the error is showing you an absolute path from the source folder on girlfriend computer.

Try installing one of these...- npm serve- Live server (an expansion for intuitive Studio password if you room using that)

Or every little thing server the will work-related with your environment.

Should occupational fine when you spin up a server :) happy coding!


re-superstructure
enhance this prize
follow
answer Sep 27 "19 at 6:36
*

Nick SugarNick street
33922 silver- badges55 bronze badges
5
add a comment |

Not the price you're spring for? Browse other questions tagged javascript promise fetch or ask your own question.


The Overflow Blog
Featured ~ above Meta
Linked
1884
Disable same origin policy in Chrome
14
Chrome - bring API cannot fill file. Exactly how to workaround?
related
852
How have the right to you check for a #hash in a URL using JavaScript?
584
“Origin null is not permitted by Access-Control-Allow-Origin” error for inquiry made by application running indigenous a file:// URL
342
how to save up another precious HTTP-request because that the small favicon?
409
How can I acquire the condition code native an HTTP error in Axios?
13
fetch API cannot pack file:///C:/Users/Jack/Desktop/Books_H/book-site/public/api/books. URL scheme have to be "http" or "https" for CORS inquiry
hot Network concerns more hot inquiries
*

lang-js
ridge Overflow
commodities
company
ridge Exchange Network
site architecture / logo © 2021 ridge Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.11.24.40828




See more: Mellon Collie And The Infinite Sadness Wallpaper, 43 Mellon Collie And The Infinite Sadness Ideas

Stack Overflow works ideal with JavaScript allowed
*

her privacy

By clicking “Accept all cookies”, you agree ridge Exchange can store cookies on your an equipment and disclose info in accordance with our Cookie Policy.