use api from js (xhr)

whoim

Member
Jul 20, 2015
32
0
6
Hello, i trying use json api from javascript. I use another domain, and browser send OPTIONS request to node. Node API not have "Access-Control-Allow-Origin" header in reply.
Result - 501 method 'OPTIONS' not available
What i may use api from js?
 
i added CORS header to httpserver.pm
$resp->header('Server' => "pve-api-daemon/3.0");
+$resp->header('Access-Control-Allow-Origin' => "*");
+$resp->header('Access-Control-Allow-Methods' => "GET, POST, OPTIONS");
+$resp->header('Access-Control-Allow-Headers' => "X-Requested-With");
but have error
OPTIONS https://x:8006/api2/json/nodes/x/qemu/x/vncproxy UI.API2Request @ pveui.js:119UI.pve_start @ pveui.js...
XMLHttpRequest cannot load https://x:8006/api2/json/nodes/x/qemu/x/vncproxy. Invalid HTTP status code 501