Hi,
I have a Node-RED setup behind Nginx. When a WebSocket connection is established, Nginx injects a verified X-Myapp-User header into the handshake request.
Using webSocketNodeVerifyClient in settings.js I can read this header:
webSocketNodeVerifyClient: function(info) {
const user = info.req.headers['x-myapp-user'] || '';
console.log('user:', user); // works fine
return true;
}
The problem is linking this user to the _session.id that Node-RED assigns to the connection and that appears in msg._session.id inside the flow.
The _session.id is generated by RED.util.generateId() inside handleConnection() — after verifyClient has already returned. So at the time of verifyClient, the session ID doesn't exist yet.
Is there any documented/stable way to:
- Store the user from
verifyClient - Retrieve it later in the flow associated with the correct
_session.id
Without modifying core files or writing a custom node?
Thanks