Proxmox VE API and CORS problem

karnalta

New Member
Jan 25, 2024
6
0
1
Hello,

I am trying to query the Proxmox API via an API key from a Blazor Webassembly app.

I can't seem to get it work, I am always denied via CORS.

pveapi.png

I did try the two proposed solutions from this thread but none of them seem to work for me.

I am quite new to web frontend development, so all these CORS issues are still a bit unclear to me..

As I understand it, it's not really a Proxmox issue, as I can query the API via a software like Postman. I am not certain of who reject the query exactly, the browser itself ? The WASM client app ?

Any help would be appreciate !
 
Hello,

I am trying to query the Proxmox API via an API key from a Blazor Webassembly app.

I can't seem to get it work, I am always denied via CORS.

View attachment 68072

I did try the two proposed solutions from this thread but none of them seem to work for me.

I am quite new to web frontend development, so all these CORS issues are still a bit unclear to me..

As I understand it, it's not really a Proxmox issue, as I can query the API via a software like Postman. I am not certain of who reject the query exactly, the browser itself ? The WASM client app ?

Any help would be appreciate !
Hi,
CORS is enforced by the browser, limiting from which domains the browser should allow loading resources from, see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS So in your case, since your webapp runs as localhost, the browser is blocking the requests to the domain the api is running on, in particular [1].

As stated by @fabian [0] in the other thread, you will have to setup a reverse proxy (e.g. nginx) which adds the required headers to allow the additional domains and perform the api requests via the proxy instead.

[0] https://forum.proxmox.com/threads/api-calls-from-webapp.81479/post-375842
[1] https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
 

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!