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
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!