wie fix ich diese fehler?
Fehler:Access to fetch at 'file:///C:/Users/justin/Documents/dev/music/app/desktop/windows/bin/songs_en.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: chrome, chrome-extension, chrome-untrusted, data, http, https, isolated-app.Fehler nachvollziehenAI
index.html:557
GET file:///C:/Users/justin/Documents/dev/music/app/desktop/windows/bin/songs_en.json net::ERR_FAILED
loadSongs @ index.html:557
MusicPlayer @ index.html:549
(anonym) @ index.html:692Fehler nachvollziehenAI
index.html:561 Error loading songs: TypeError: Failed to fetch
at MusicPlayer.loadSongs (index.html:557:36)
at new MusicPlayer (index.html:549:14)
at index.html:692:16
Der quellcode ist zulang. hier ist der link zu pastebin, werde es löschen nach dem meine frage beantwortet wurde.
https://pastebin.com/2jiMawCv
vielen dank im voraus!
1 Antwort
Vom Beitragsersteller als hilfreich ausgezeichnet
Der Fehler liegt daran, dass file:///-Zugriffe von CORS blockiert werden. Starte einen lokalen Server, z. B. mit python -m http.server. Passe den Pfad an, um die Datei über http://localhost/... zu laden. So sollte es funktionieren.
hab ich, passiert trotzdem...
Hier der code denn ich verwende:
https://pastebin.com/hyMgC4Vq