Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

236
Vistas
How to access Express-style request objects when upgrading to websocket?

Using Express + ws (websocket) libraries.

"App" uses some Express middleware to add the current user to the request object, but WS gets a Node request object without the information I need.

How can I pass this data to the websocket when upgrading connection?

const server = http.createServer(app); // app is using the express middleware to add info I need

const wss: WebSocket.Server = new WebSocketService(clients, { noServer: true }).wss;

server.on('upgrade', (request, socket: any, head) => {
    wss.handleUpgrade(request, socket, head, (ws: WebSocket) => {
        wss.emit('connection', ws, request);
    });
});

server.listen(3000, () => {
    console.log('Listening on port 3000');
});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda