I have setup a flask http server properly configured to accept CORS requests (for the purpose of creating a userscript web filter), but am unable to send HTTP requests via tampermonkey, with the following code.
// ==UserScript==
// @name CORS test
// @namespace John Galt
// @version 1
// @grant none
// ==/UserScript==
var request = new XMLHttpRequest();
request.open("GET", "127.0.0.1:5000", false);
request.send();
alert("Finished");
"Finished" is not alerted indicating the failure of the operation, and the following error appears in the console:
XMLHttpRequest cannot load %3127.0.0.1:5000. Cross origin requests are only supported for HTTP. rand.html:1
ERROR: Execution of script 'CORS test' failed! Failed to execute 'send' on 'XMLHttpRequest': Failed to load '%3127.0.0.1:5000'.
Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load '%3127.0.0.1:5000'.
at Error (native)
at Object.eval (eval at <anonymous> (unknown source), <anonymous>:19:9)
at Object.eval (eval at <anonymous> (unknown source), <anonymous>:23:4)
at e (<anonymous>:41:76)
at eval (eval at <anonymous> (unknown source), <anonymous>:1:24)
at eval (native)
at m (<anonymous>:68:246)
at Z (<anonymous>:41:92)
at aa (<anonymous>:78:392)
at b (<anonymous>:79:109)
I have no experience with front-end so could someone point out if this is a problem with my server configuration or something on the front-end, and if so, is there a workaround?