I’d like to query vk.com API (popular russian social network site) from Haxe code.
So I made this code:
package;
class Main {
public static function main() {
var http = new haxe.Http("https://api.vk.com/method/users.get?user_id=1");
http.onData = function (data) {
trace(data);
};
http.request(false);
}
}
And I’m compiling it to javascript and including to html page like so:
<!DOCTYPE html>
<html lang=“ru”>
<head>
<meta charset=“UTF-8”>
<meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
<meta http-equiv=“X-UA-Compatible” content=“ie=edge”>
<title>VK</title>
</head>
<body>
<script src=“main.js”></script>
</body>
</html>
It compiles fine, however when I open the html file with firefox I get an error that the request was blocked as there is no CORS header (I’m having an error message in russian and I don’t know how to translate this message to english properly, sorry). When I tried to google it I only find the answers that suggest adding some headers to the server code, but I don’t have access to server code, it’s a public api. Does anyone know how I can fix this issue atleast for testing purposes?
I tried hosting the files using “python -m SimpleHTTPServer”, however the issue still remains. However it may be that I’m trying to make request from HTTP “site” to HTTPS site.