At 10/23/15 06:14 PM, MaxPoly wrote:
I want to create a sort of radio functionality in the game I'm working on, which will be hosted on NG. Is this permitted? How might I go about doing that?
In NetBeans, when I debug on localhost, it appears that NG doesn't allow these sorts of requests. I guess this is to reduce bandwidth usage.
My guess is that the game content and the audio content you're trying to access are hosted at different domains, at which point your browser's same-origin policy will prevent the request from being fulfilled. Essentially, this is a safety feature in browsers that prevents rogue scripts (scripts not hosted on the same domain you're accessing the website from) from talking to a server they have no business talking to. It's intended to prevent stealing/modifying.
There is a way to get around it, but it requires changes on the server you want to access (audio.ngfiles.com) to indicate that the domain your script lives on is allowed to make XHR requests to it.
I don't think NG will want to make those changes given the security implications, though.
Further reading:
Cross-origin resource sharing (Wikipedia)
Using CORS (HTML5Rocks)