CORS error in Firefox #329
Unanswered
TheNoceboEffect
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am developing a Scratch extension, and when trying to use the Web Audio API in my code, I encountered a CORS error, and I originally used the code : "myFirstBlock ({ MY_STRING }) {
function loadSound(url) {
return fetch(url)
.then(response => response.arrayBuffer())
.then(arrayBuffer => audioContext.decodeAudioData(arrayBuffer));
}
}
module.exports = Scratch3YourExtension;" in my code, however when trying to fix the CORS errors I received ([Error] Fetch API cannot load https://github.com/TheNoceboEffect/audiotesting/raw/master/sounds/[object%20Object]undefined; due to access control checks.
[Error] Failed to load resource: Origin https://bug-free-journey-5jg9rwqppvw3pv5w-8000.app.github.dev/ is not allowed by Access-Control-Allow-Origin. Status code: 404 ([object Object]undefined;, line 0)[Error] Not allowed to load local resource: blob://nullhttps//bug-free-journey-5jg9rwqppvw3pv5w-8000.app.github.dev/4f46f43b64af7fd567fc.worker.js.map), using the code "myFirstBlock ({ MY_STRING }) {
function loadSound(url) {
return fetch(url)
.then(response => response.arrayBuffer())
.then(arrayBuffer => audioContext.decodeAudioData(arrayBuffer));
}
}
module.exports = Scratch3YourExtension;" to play sounds in my extension, however I received the errors "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www./github.com/TheNoceboEffect/audiotesting/raw/master/sounds/aundefined;. (Reason: CORS request did not succeed). Status code: (null)." and "Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource." in Firefox. I also made sure to put "const audioContext = new (window.AudioContext || window.webkitAudioContext)();" at the top of my code to define the audio context for the API I was using, the Web Audio API.
Does anyone know how to fix this error?
Beta Was this translation helpful? Give feedback.
All reactions