question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SockJsClient authentication headers

See original GitHub issue

Hello, I have question about authentication header adding while subscribing to server.

I am trying to do it like this:

       <SockJsClient url={ wsSourceUrl } topics={[this.state.channelId]} headers={"Authorization: `Bearer ${this.token}`"}
          onMessage={ this.onMessageReceive } ref={ (client) => { this.clientRef = client }}
          onConnect={ () => { this.setState({ clientConnected: true }) } }
          onDisconnect={ () => { this.setState({ clientConnected: false }) } }
          debug={ false }/>

But Header isn’t getting set. What I am doing wrong?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
AndrewMerkecommented, Sep 18, 2018

@lahsivjar, it was problem in my CORS configuration. Thank you for your patience 😃 Headers works well.

1reaction
crisilva95commented, Jan 7, 2021

@Prasad-YS How did your solve it? I have the exact same problem, headers don’t even show up on the request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Providing auth header with SockJS - Stack Overflow
I'm using JWT to authenticate requests coming from the client. When the user logs in I'm returning an X-AUTH-TOKEN header, containing the JWT ......
Read more >
SockJsClient
Set it if you want only a subset of handshake headers (e.g. auth headers) to be used for other HTTP requests. Parameters: httpHeaderNames...
Read more >
Accessing header in STOMP web socket connection ... - Medium
Hi, I am currently working at https://mealpha.com as spring boot developer and working on a chat application using spring web sockets.
Read more >
26. WebSocket Support - Spring
Instead of using cookies they may prefer to authenticate with headers at the STOMP messaging protocol level There are 2 simple steps to...
Read more >
Authenticated websocket connection with Spring Boot and ...
getNativeHeader(WebSocketHttpHeaders.AUTHORIZATION)) .orElse(Collections.emptyList()); // if header does not exists returns null instead ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found