Setting Websocket Headers dynamically

moreelremy
Wed, 22 May 2024 09:46:57 +0000
General

Hello, I'm currently running on the latest update of NodeRED (v4.0.0-beta.3-1) because of the Websockets new feature that allows you to set headers before the connection request.

The thing is that I need to generate a Bearer token with a POST request before establishing the connection to the websocket.
It works perfectly fine when I manually generate the token and put it into the authorization header of the websocket, but the token last at most an hour, leading me to reset manually the token each time the connection to the websocket close and reconnect or when I restart Node-RED.

Is there a way to change the header of the websocket node before it tries to connect, when the token is no more accepted (I already do that for classic https request and it work perfectly fine) ?

Thanks in advance

6 posts - 3 participants