--headauth <method> and WebSocket

Is there is any example code with headauth and Websocket? I am using WebSocket with header Authorization set, but donot see headauth getting called.

Hi, and welcome to the forum! :slight_smile:

headerauth is only used by HTTP requests at the moment. Not WebSocket. It will likely change in the future (when support for setting cookies is implemented), but for now you can call it manually from the ResClient.setOnConnect callback:

let client = new ResClient("ws://");
client.setOnConnect(c => client
    .authenticate('auth', 'jwtHeader') // same as headerauth "auth.jwtHeader"
    .catch(err => console.log("Failed to log with headers"));

It will behave similar, but will be sent after the connection is established, prior to any other request, allowing you to check if the call went well or not.

You can see it used in the index.html file of the jwt-authentication example.

Hope that helps.

Best regards,