Antoine Grenard
Antoine Grenard

Reputation: 1892

Proxy socket.io with from react to nestjs

I am currently working with :

I am trying to access my gateways at the same url using proxy but it does not work. Here is my configuration :

conversation.ts:

socket = io('/service-conversation');

setupProxy.js :

const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function (app) {
  app.use(
    '/api',
    createProxyMiddleware({
      target: 'http://127.0.0.1:8000/api',
    })
  );
  app.use(
    'socket.io',
    createProxyMiddleware({
      target: 'http://127.0.0.1:3000',
      ws: true,
    })
  );
};

gateway.ts :

@WebSocketGateway({
  cors: true,
  namespace: 'service-conversation',
})
export class ConversationGateway {
  @WebSocketServer() webSocketServer: Server;

To give some insight I tried :

Upvotes: 0

Views: 28

Answers (0)

Related Questions