Hello I have next two files:
testsse.html
<!DOCTYPE html>
<h1>Test of server sent events</h1>
<script>
var eventSource = new EventSource("sse.php");
eventSource.onmessage = function(event) {
console.log("It works");
};
eventSource.onerror = function(error) {
console.error("eventSource failed: ", error);
};
</script>
And sse.php
<?php
header("Content-Type: text/event-stream
");
header('Cache-Control: no-cache');
echo "ssetest
";
flush();
?>
So in console there are a lot of errors, and in the network tab a lot of pings, here the screenshots:
MDN says if response from server is 200, means all is ok, but in network tab you can clearly see there are response code 200, but still erorrs at console that are very big. Code is very small and easy so I dont even know what is causing problem. Also path to sse.php is correct (I hide it from screenshots with black boxes)
question from:
https://stackoverflow.com/questions/66047672/server-sent-events-error-despite-http-200 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…