You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The socket.io-implementation is removing every listener on the requests and therefore any kind of adjustment on the headers (e.g. from the surrounding express-server) is not possible.
If it is necessary to add a header to the socket.io-calls (e.g. 'X-Content-Type-Options'), a manipulation of the used socket.io-lib is inevitable.
Expected behaviour
It should be possible to add/adjust headers to the socket.io-server, which are used for all the responses created by the socket.io-server.
Setup
OS: Ubuntu
browser: Chrome, Firefox
socket.io version: 2.3.0
The text was updated successfully, but these errors were encountered:
Those events will be emitted before the response headers are written to
the socket:
- "initial_headers": on the first request of the connection
- "headers": on all requests
Syntax:
```js
server.on("initial_headers", (headers, req) => {
headers["test"] = "123";
headers["set-cookie"] = "mycookie=456";
});
server.on("headers", (headers, req) => {
headers["test"] = "789";
});
```
Related:
- #557
- socketio/socket.io#3630
Those events will be emitted before the response headers are written to
the socket:
- "initial_headers": on the first request of the connection
- "headers": on all requests (HTTP long-polling and WebSocket upgrade)
Syntax:
```js
server.on("initial_headers", (headers, req) => {
headers["test"] = "123";
headers["set-cookie"] = "mycookie=456";
});
server.on("headers", (headers, req) => {
headers["test"] = "789";
});
```
Related:
- #557
- socketio/socket.io#3630
You want to:
Current behaviour
The socket.io-implementation is removing every listener on the requests and therefore any kind of adjustment on the headers (e.g. from the surrounding express-server) is not possible.
If it is necessary to add a header to the socket.io-calls (e.g. 'X-Content-Type-Options'), a manipulation of the used socket.io-lib is inevitable.
Expected behaviour
It should be possible to add/adjust headers to the socket.io-server, which are used for all the responses created by the socket.io-server.
Setup
The text was updated successfully, but these errors were encountered: