title: How to fix CORS when using React, Node.js and Socket.io (v 4.0.0)
body: <p>I'm having issues with CORS in production when using React, Socket.io, and Node.js.</p>
  <p>Client Side:</p>
  <pre><code>import { io } from 'socket.io-client';
  const socket = io('https://warm-wildwood-81069.herokuapp.com');
  </code></pre>
  <p>Server Side:</p>
  <pre><code>const app = require(&quot;express&quot;)();
  const server = require(&quot;http&quot;).createServer(app);
  
  const io = require(&quot;socket.io&quot;)(server, {
      cors: {
          origin: &quot;https://priceless-swirles-68e598.netlify.app&quot;,
          methods: [ &quot;GET&quot;, &quot;POST&quot; ]
      }
  });
  </code></pre>
  <p>Both client and server are running 4.0.0 version of Socket.io.</p>
  <p>The errors that I'm getting are as follows:</p>
  <pre><code>Access to XMLHttpRequest at 'https://warm-wildwood-81069.herokuapp.com/socket.io/?EIO=4&amp;transport=polling&amp;t=NXV7rQn' from origin 'https://priceless-swirles-68e598.netlify.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  </code></pre>
  <p>and:</p>
  <pre><code>GET https://warm-wildwood-81069.herokuapp.com/socket.io/?EIO=4&amp;transport=polling&amp;t=NXV7rQn net::ERR_FAILED
  </code></pre>
  <p>Live Demo: <a href="https://priceless-swirles-68e598.netlify.app" rel="nofollow noreferrer">https://priceless-swirles-68e598.netlify.app</a></p>