I'm testing JS with POST. But I didn't get success with that.
Using the code:
<!DOCTYPE html>
<html>
<body>
<div>
testing js...
</div>
<script>
function upload() {
var method = "POST";
var url = "http://127.0.0.1:9000/push";
var xhr = new XMLHttpRequest();
xhr.open(method, url);
xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
var text = {"command":"PUSH"};
xhr.send(text);
}
upload();
</script>
</body>
</html>
I'm getting the following error:
The weird is that the request header is not being set correctly through the line:
xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
The request header is like this: