add put and delete proxmox proxy routes
This commit is contained in:
parent
1ffe9fbe7c
commit
c347a3b8c0
@ -6,7 +6,6 @@ export const router = Router({ mergeParams: true }); ;
|
|||||||
* request and responses passed through to/from proxmox
|
* request and responses passed through to/from proxmox
|
||||||
*/
|
*/
|
||||||
router.get("/*", async (req, res) => { // proxy endpoint for GET proxmox api with no token
|
router.get("/*", async (req, res) => { // proxy endpoint for GET proxmox api with no token
|
||||||
console.log(req.url);
|
|
||||||
const path = req.url.replace("/api/proxmox", "");
|
const path = req.url.replace("/api/proxmox", "");
|
||||||
const result = await global.pve.requestPVE(path, "GET", { cookies: req.cookies });
|
const result = await global.pve.requestPVE(path, "GET", { cookies: req.cookies });
|
||||||
res.status(result.status).send(result.data);
|
res.status(result.status).send(result.data);
|
||||||
@ -22,3 +21,24 @@ router.post("/*", async (req, res) => { // proxy endpoint for POST proxmox api w
|
|||||||
const result = await global.pve.requestPVE(path, "POST", { cookies: req.cookies }, body); // need to stringify body because of other issues
|
const result = await global.pve.requestPVE(path, "POST", { cookies: req.cookies }, body); // need to stringify body because of other issues
|
||||||
res.status(result.status).send(result.data);
|
res.status(result.status).send(result.data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PUT - proxy proxmox api without privilege elevation
|
||||||
|
* request and responses passed through to/from proxmox
|
||||||
|
*/
|
||||||
|
router.put("/*", async (req, res) => { // proxy endpoint for POST proxmox api with no token
|
||||||
|
const path = req.url.replace("/api/proxmox", "");
|
||||||
|
const body = JSON.parse(JSON.stringify(req.body));
|
||||||
|
const result = await global.pve.requestPVE(path, "PUT", { cookies: req.cookies }, body); // need to stringify body because of other issues
|
||||||
|
res.status(result.status).send(result.data);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE - proxy proxmox api without privilege elevation
|
||||||
|
* request and responses passed through to/from proxmox
|
||||||
|
*/
|
||||||
|
router.delete("/*", async (req, res) => { // proxy endpoint for GET proxmox api with no token
|
||||||
|
const path = req.url.replace("/api/proxmox", "");
|
||||||
|
const result = await global.pve.requestPVE(path, "DELETE", { cookies: req.cookies });
|
||||||
|
res.status(result.status).send(result.data);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user