yjs / y-websocket

Websocket Connector for Yjs
https://docs.yjs.dev/ecosystem/connection-provider/y-websocket
MIT License
524 stars 262 forks source link

fix(src): websocket provider set header #77

Closed ChasLui closed 3 years ago

ChasLui commented 3 years ago

use provider in nodejs, should set cookie to auth

Huly®: YJS-769

dmonad commented 3 years ago

I like this. But the last time I checked not all browsers supported headers in Websocket connections. Some just ignore the headers option. Can you please check whether this works in Chrome, Firefox, and Safari?

ChasLui commented 3 years ago

I like this. But the last time I checked not all browsers supported headers in Websocket connections. Some just ignore the headers option. Can you please check whether this works in Chrome, Firefox, and Safari?

Unfortunately, the websocket headers cannot be set in Chrome, Firefox, and Safari browsers

dmonad commented 3 years ago

I'm a bit confused. So what does this PR achieve?

hanspagel commented 3 years ago

I think he wants support in Node.js (see initial comment).

ChasLui commented 3 years ago

I'm a bit confused. So what does this PR achieve?

When using require('ws') as WebSocketPolyfill in nodejs, it is necessary to set the cookie. For more details, see https://github.com/websockets/ws/issues/1411

dmonad commented 3 years ago

Setting a cookie is optional. But since this would only enable cookies in Websocket provided by ws, and because it is incompatible with the Websocket constructor provided by the browser, I'm hesitant to merge this.