Closed yalamber closed 2 years ago
Hello!
In general that depends on the way your backend/broker expects you to authenticate. You can use the beforeConnect callback to set additional headers before the connection is made, e.g. like so:
const beforeStompConnect = useCallback(function () {
this.connectHeaders = {
'Authorization': "Bearer " + apitoken
}
}, [apitoken]);
return (
<StompSessionProvider
url={`/api/sock/`}
beforeConnect={beforeStompConnect}
>
...
</StompSessionProvider>
);
Hello!
I am trying to add the 'Authorization' header into the connection on the StompSessionProvier. I have tried to use the code of your example, but the request to the server is not including the 'Authorization' header. Any idea how could I add it?
Thanks, Joan
what is correct way to pass username and password?