Yes, I agree that raw.githubusercontent.com works, while github.com doesn't (just tested again).
The Web IDE is able to detect github-style URLs and although raw.githubusercontent.com doesn't work, it uses the GitHub API to request the file in a way which DOES work cross origin
Hm. I don't think I can agree with either half of that sentence. If I open raw.githubusercontent.com in my browser and check the request headers, access-control-allow-origin: * is passed, which mean it should allow all cross origin requests.
If I check the requests made by the Web IDE, it sends a fetch request to either raw.githubusercontent.com or github.com, depending ofc which you enter in the require call. I don't see a GitHub API request.
I can be totally wrong though, never done any JS work. But from the previous two comments from us, I would have made a change to the web IDE just checking if the require is a GitHub.com URL and change it to a raw one, as a hotfix. And then I would have opened an Issue at GitHub asking why they dont pass a cross origin header in GitHub.com and if they have a good reason not to, I guess the hotfix will be a permanent fix.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Yes, I agree that raw.githubusercontent.com works, while github.com doesn't (just tested again).
Hm. I don't think I can agree with either half of that sentence. If I open raw.githubusercontent.com in my browser and check the request headers,
access-control-allow-origin: *
is passed, which mean it should allow all cross origin requests.If I check the requests made by the Web IDE, it sends a fetch request to either raw.githubusercontent.com or github.com, depending ofc which you enter in the require call. I don't see a GitHub API request.
I can be totally wrong though, never done any JS work. But from the previous two comments from us, I would have made a change to the web IDE just checking if the require is a GitHub.com URL and change it to a raw one, as a hotfix. And then I would have opened an Issue at GitHub asking why they dont pass a cross origin header in GitHub.com and if they have a good reason not to, I guess the hotfix will be a permanent fix.