Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to add custom headers? #28

Closed
geekbleek opened this issue Jun 5, 2018 · 1 comment
Closed

Ability to add custom headers? #28

geekbleek opened this issue Jun 5, 2018 · 1 comment

Comments

@geekbleek
Copy link

geekbleek commented Jun 5, 2018

I don't see any option to add custom headers to the WS connection. I know this may not be used for browser based implementations of websocket connections, but many server-side client libs need to provide an Authorization header to connect to a websocket. Is this something you could see using on this project? Thanks!

@lukeed
Copy link
Owner

lukeed commented Nov 13, 2018

Hey there,

Unfortunately no, sorry. The browser WebSocket does not allow this behavior so there's no means/purpose in Sockette adding support for it. You can sorta go about this on the browser via protocols, but even so, that's writing into the Sec-WebSocket-Protocol header.

Not certain, but another option is to append a token to the url you're connecting to; ws://localhost:3000?token=abc-123.

This is a nice paper trail: websockets/ws#1333

That said, if you're using Sockette in the server (with a custom WebSocket global), each event handler receives the current ws instance as its event target. Whatever server implementation you are using will be available inside those handlers.

If it were possible, I'd be all for it!

Thanks!

@lukeed lukeed closed this as completed Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants