title: How to fix 400 error bad request in socket io?
body: <p>I have a frontend application(VUE JS)</p>
  <p>I have a backend (Nest JS)</p>
  <p>Vue JS app get data from backend via websockets using vue-socket.io-extended library
  When Vue JS app starts I see errors in browser:</p>
  <blockquote>
  <p>polling-xhr.js?d33e:229 POST
  http://localhost:11050/socket.io/?EIO=4&amp;transport=polling&amp;t=NMXgCF1
  400 (Bad Request)</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/ruEKy.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ruEKy.jpg" alt="error" /></a></p>
  <p><strong>How can I fix this error?</strong></p>
  <p>I think it is not connected with library, I tried just socket io library and the result was the same.</p>
  <p>Server is working, because it sends logs and show who is connected:</p>
  <p><a href="https://i.stack.imgur.com/d1VrH.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/d1VrH.jpg" alt="server respond" /></a></p>
  <p><strong>Server(Nest JS)</strong>
  main.ts file:</p>
  <pre><code>async function bootstrap() {
    const app = await NestFactory.create(AppModule);
    app.enableCors();
    await app.listen(11050);
  }
  bootstrap();
  </code></pre>
  <p>App.gateway:</p>
  <pre><code>@WebSocketGateway()
  export class AppGateway implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect {
  
  
    private logger: Logger = new Logger('AppGatway');
  
    @SubscribeMessage('msgToServer')
    handleMessage(client: Socket, text: string): WsResponse&lt;string&gt; {
      return { event: 'msgToClient', data: text };
    }
  
    afterInit(server: Server) {
      this.logger.log('Initialised!');
    }
  
    handleConnection(client: Socket, ...args: any[]): any {
      this.logger.log(`Client connected: ${client.id}`);
    }
  
    handleDisconnect(client: Socket): any {
      this.logger.log(`Client disconnected: ${client.id}`);
    }
  }
  </code></pre>
  <p><strong>Frontend(Vue JS):</strong></p>
  <pre><code>import VueSocketIOExt from &quot;vue-socket.io-extended&quot;;
  import Vue from &quot;vue&quot;;
  import io from &quot;socket.io-client&quot;;
  const socket = io(&quot;http://localhost:11050/&quot;);
  
  Vue.use(VueSocketIOExt, socket);
  
  data: () =&gt; ({
  socket: null,
      connection: null,
      sockets: {
        connect() {
          console.log(&quot;socket connected&quot;);
        },
      },
  }
  </code></pre>