As I utilize window.fetch to fetch a YouTube resource with the given URL:
http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=[id]&format=json
Upon inspecting through Fiddler, I can confirm that I am receiving the anticipated response from YouTube's servers, containing JSON data. However, an issue arises as I encounter a Javascript error.
The issue is related to the absence of the 'Access-Control-Allow-Origin' header in the requested resource. Consequently, the origin 'http://localhost:60366' is not granted access.
My attempt at enabling CORS on my window.fetch is proving futile due to the lack of the CORS header in YouTube's server response.
How can I configure my script to accept responses from YouTube using window.fetch? (Using Chrome v44.)
window.fetch(
url, {
method: 'GET',
mode: 'cors',
headers: {
'Accept': 'text/plain',
'Content-Type': 'text/plain'
}
})
...