I have a simple Python server that responds “ALIVE” to every request and is wrapped in CORS with flask-cors
.
When sending an XMLHttpRequest from any other browser (Chromium 127 and Firefox 129 on Linux, Palemoon 33.2.1 on Windows 7), the server gets it, prints that it got it (127.0.0.1 - - [date] "GET / HTTP/1.1" 200 -
), and the browser gets a response.
When sending an XMLHttpRequest from IE8, the log in the browser is displayed that the request has been sent, but the server doesn’t get it.
I tried substituting the server for http://google.com/ and http://example.com/, and IE8 still doesn’t get a response, while other browsers work fine.
Minimal reproducible example:
Page:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Broken Ajax MRE</title>
</head>
<body>
<script type="text/javascript">
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://localhost:8080", true);
xhr.onload = function () {
console.log("Responded: " + xhr.status + " " + xhr.response);
};
xhr.onerror = function () {
console.log("Network Error!");
};
xhr.send();
console.log("Sent");
</script>
</body>
</html>
Server:
from flask import Flask
from flask_cors import CORS, cross_origin
app = Flask(__name__)
CORS(app)
@app.route("/")
def is_alive():
return "ALIVE"
app.run(host="127.0.0.1", port=8080)
What am I doing wrong?