title: Socket.io server getting 405 error with heroku deploy
body: <p>I'm fairly new to node.js/express and socket.io. I built an app using ruby on rails for the backend api and react for the frontend. I tried to implement socket.io for the real time chat message portion of the app (which does not use the rails backend api except to save messages that were sent). I've implemented the socket.io server and client files into the react frontend using node and express. Here's the server side code:</p>
  <pre><code>const express = require('express')
  const app = express()
  const cors = require('cors')
  const server = require('http').createServer(app)
  const PORT = process.env.PORT || 3000
  
  server.listen(PORT, () =&gt; console.log(`Listening on ${PORT}`))
  
  app.use(cors())
  
  const socket = require('socket.io')
  const io = socket(server)
  
  io.on('connect', (socket) =&gt; {
      console.log('Connected')
      socket.on('disconnect', () =&gt; console.log('Disconnected'))
  })
  </code></pre>
  <p>and the client side code:</p>
  <pre><code>import openSocket from 'socket.io-client'
  
  const socket = openSocket()
  
  socket.on('connect', () =&gt; {
      console.log('connected')
  })
  </code></pre>
  <p>When I test out the code in local using <code>npm start</code> and <code>nodemon server.js</code>, everything seems to work and  I can see the &quot;Connected&quot; message from the console. However, when I tried to deploy to Heroku, I'm getting a 405 error without much details:</p>
  <pre><code>polling-xhr.js:268 POST https://vir-clsrm.herokuapp.com/socket.io/?EIO=3&amp;transport=polling&amp;t=NIicfiD 405 (Not Allowed)
  </code></pre>
  <p>I've tried implementing cors thinking that might be the issue, but it didn't seem to help at all. I've also enable session affinity in Heroku but that didn't change anything either. Not sure what to do at this point. Would greatly appreciate any help or insight.</p>