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.
improve this concern
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
| present 1 much more comment
1 answer 1
energetic earliest Votes
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!
enhance this prize
answer Sep 27 "19 at 6:36
Nick SugarNick street
33922 silver- badges55 bronze badges
add a comment |
The Overflow Blog
Featured ~ above Meta
Disable same origin policy in Chrome
Chrome - bring API cannot fill file. Exactly how to workaround?
“Origin null is not permitted by Access-Control-Allow-Origin” error for inquiry made by application running indigenous a file:// URL
how to save up another precious HTTP-request because that the small favicon?
How can I acquire the condition code native an HTTP error in Axios?
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
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