title: Issue to add socketio to API Express
body: <p>i'm trying to add socket.io on my already existing NodeJS API REST Project.</p>
  <pre><code>var express = require('express')
  var bodyParser = require('body-parser');
  var https = require('https');
  var http = require('http');
  var fs = require('fs');
  var router = require('./route/router');
  require('dotenv').config();
  
  var app = express();
  
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(bodyParser.json());
  
  app.use(require('helmet')());
  
  app.use(function (req, res, next) {
      res.setHeader('Access-Control-Allow-Origin', '*');
      res.setHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
      res.setHeader('Access-Control-Allow-Headers', 'Authorization,Content-Type');
      next();
  });
  
  router(app);
  
  if (process.env.PRODUCTION === &quot;false&quot;) {
      http.createServer(app).listen(8080, function() {
          console.log('8080 ok');
      });
  
      var io = require('socket.io')(http);
  } else {
      const options = {
          cert: fs.readFileSync('./../../etc/letsencrypt/live/test.com/fullchain.pem'),
          key: fs.readFileSync('./../../etc/letsencrypt/live/test.com/privkey.pem')
      };
  
      https.createServer(options, app).listen(8443, function() {
          console.log('8443 ok');
      });   
  
      var io = require('socket.io')(https);
  }
  
  io.sockets.on('connection', socket =&gt; {
    console.log('socketio connected');
  });
  </code></pre>
  <p>I have no error displayed (server side). But, when I tried on client side, <code>this.socket = io('ws://localhost:8080/');</code>, it's not working at all.</p>
  <p>I get <code>GEThttp://localhost:8080/socket.io/?EIO=3&amp;transport=polling&amp;t=NG6_U6i [HTTP/1.1 404 Not Found 1ms]</code> browser console.</p>
  <p>It seems that something is not ok with the server, but I can't find what's going on</p>
  <p>Any idea ?</p>
  <p>Thanks</p>