Here is what i have altered my code to after the last post:
I have this page that only has one button, when the page is loaded it comes with the PVE ticket in the cookies as shown in the image bellow (im not showing the cookie since it has a valid ticket, but i can see the cookie has been set)
the redirect button runs the following code to get that will be use for the noVNC, that info is added in the query variables so i have to url encode it as shown bellow
then it opens the following page, which i got from the proxmox git mentioned before in this thread, the only info i have are the ticket in the cookies (a PVE ticket) and the ticket and port present in the path (a PVEVNC ticket)
I then try to connect by clicking the connect button and get the following error:
as for my backend code, i basically just divided the code i already posted here, so that the cookies are set on page load and the PVEVNC ticket is acquired when i press the redirect button, but just to be sure here is the code im running:
To get the ticket that goes in the cookies:
To get the port and PVEVNC ticket:
Also relevant is the code im using to create the encodedParams variable, here it is:
Everything else i have is just boilerplate to load the page and the cookies.
Ps. thought it might be good to show how im setting the cookies to see if im doing it wrong:
This is all the info related to the connection that i can think of adding to the post to try and share my problem. But if you think something is missing please let me know.
I have this page that only has one button, when the page is loaded it comes with the PVE ticket in the cookies as shown in the image bellow (im not showing the cookie since it has a valid ticket, but i can see the cookie has been set)
the redirect button runs the following code to get that will be use for the noVNC, that info is added in the query variables so i have to url encode it as shown bellow
JavaScript:
function redirectToVNC(){
fetch(window.location.origin+ "/vnc/getVNCInfo",
{
method: "GET",
}
)
.then((result)=>result.json())
.then((result)=>{
console.log(result)
window.location.href = window.location.origin + "/vnc?" +
"path=" + encodeURIComponent('api2/json/nodes/pve/qemu/100/vncwebsocket' + "?" + result.encodedParams)
})
.catch((err)=>{
console.log(err)
})
}
then it opens the following page, which i got from the proxmox git mentioned before in this thread, the only info i have are the ticket in the cookies (a PVE ticket) and the ticket and port present in the path (a PVEVNC ticket)
I then try to connect by clicking the connect button and get the following error:
as for my backend code, i basically just divided the code i already posted here, so that the cookies are set on page load and the PVEVNC ticket is acquired when i press the redirect button, but just to be sure here is the code im running:
To get the ticket that goes in the cookies:
JavaScript:
async getPVETicket(){
return fetch(
'https://mydns:8006/api2/json/access/ticket',
{
method: "POST",
headers:{
"Content-Type": "application/x-www-form-urlencoded"
},
body: new URLSearchParams({
'username': "amyfakeruser",
'password': "1234"
})
}
)
.then((result)=>{
return result.json()
}).
then((result)=>{
return result
})
}
To get the port and PVEVNC ticket:
JavaScript:
async getPortAndPVEVNCTicket(){
return fetch(
'https://mydns:8006/api2/json/nodes/pve/qemu/100/vncproxy',
{
method:"POST",
headers:{
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "PVEAPIToken=myfakeuser@pve!test=7DD751EE-7e39-49a3-8718-08cf77fg5taf"
}
}
)
.then((result)=>result.json())
.then((result)=>{
return result
})
}
JavaScript:
let resultPortAndPVEVNCTicket = await this.vncService.getPortAndPVEVNCTicket();
let paramsBeforeEncoding: any= {
port: resultPortAndPVEVNCTicket.data.port,
vncticket: resultPortAndPVEVNCTicket.data.ticket
}
for (i in paramsBeforeEncoding) {
if (paramsBeforeEncoding.hasOwnProperty(i)) {
value = paramsBeforeEncoding[i];
if (value === undefined) value = '';
params.push(encodeURIComponent(i) + '=' + encodeURIComponent(String(value)));
}
}
let encodedParams = params.join('&');
Everything else i have is just boilerplate to load the page and the cookies.
Ps. thought it might be good to show how im setting the cookies to see if im doing it wrong:
JavaScript:
.header('Set-Cookie', "PVEAuthCookie="+ resultPVETicket.data.ticket +";SameSite=Lax;Domain=mydns;Path=/")
This is all the info related to the connection that i can think of adding to the post to try and share my problem. But if you think something is missing please let me know.