[SOLVED] Hello, I have a question about the noVNC 401 (No Ticket) error.

shbaek

New Member
Dec 5, 2024
11
0
1
I am currently developing an integrated web application for Proxmox. The frontend is built with Angular, and the backend uses Node.js with Express. After deploying the application using Docker and testing the noVNC connection, I consistently encounter a 401 error. Below is the relevant
code:
Express:
Code:
app.post('/express/api/vnc-console', (req, res) => {

    const { node, vmid } = req.body;



    if (!node || !vmid) {

        return res.status(400).send({ error: 'Node and VM ID are required' });

    }



    // Login to Proxmox

    loginToProxmox((err, loginData) => {

        if (err) {

            console.error('Login error:', err);

            return res.status(500).send({ error: 'Failed to login to Proxmox' });

        }



        const { ticket, CSRFPreventionToken } = loginData;



        res.send({

            ticket,

            CSRFPreventionToken,

        });

    });

});

Angular:
Code:
this.proxmoxService.getVncUrl('ttc', 'test').subscribe({

    next: (response: any) => {

        const ticket = response.ticket;

        const csrfToken = response.CSRFPreventionToken;



        // Generate Proxmox URL

        this.proxmoxUrl = `https://192.168.32.99:8006/?console=kvm&novnc=1&vmid=2002&vmname=DMZ-DB-Server&node=testServer&resize=off&cmd=`;



        document.cookie = `PVEAuthCookie=${ticket}`;



        const headers = new HttpHeaders({

            'PVEAuthCookie': ticket,

            'CSRFPreventionToken': csrfToken,

        });



        this.http.post(`${this.proxmoxUrl}`, {}, {

            headers,

            withCredentials: true,

        }).subscribe({

            next: (res) => {

                const iframe = document.getElementById('vncFrame') as HTMLIFrameElement;

                iframe.src = this.proxmoxUrl;

            },

            error: (err) => {

                console.error('Error during connection:', err);

            },

        });

    },

    error: (error) => {

        console.error('Failed to get VNC URL:', error);

    },

});


Despite setting the PVEAuthCookie and CSRFPreventionToken, the connection fails with a 401 error. Interestingly, when I manually navigate to the Proxmox URL in the same browser session, the connection works without issues.

I would greatly appreciate any guidance on how to resolve this issue. Thank you!
 
Last edited:

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!