title: Fastify & Socket.io CORS not accepted
body: <p>I'm tring to set up fastify-socket.io, fastify-cors, but I'm still getting CORS errors.</p>
  <p>I have fastify-cors and fastsity-socket.io registered</p>
  <pre><code>Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5000/socket.io/?EIO=4&amp;transport=polling&amp;t=NoUUJ6g. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
  </code></pre>
  <p>Here is the back-end code:</p>
  <pre><code>import fastify from &quot;fastify&quot;;
  import fastifyIO from &quot;fastify-socket.io&quot;;
  import fastifyCors from &quot;fastify-cors&quot;;
  
  const server = fastify();''
  const PORT = 5000;
  
  server.register(fastifyIO);
  server.register(fastifyCors),
    {
      origin: &quot;*&quot;,
      methods: &quot;GET,POST,PUT,PATCH,DELETE&quot;,
    };
  
  server.listen(PORT, () =&gt; {
    console.log(`Server running on port:${PORT}`);
  });
  
  server.get(&quot;/&quot;, (request, reply) =&gt; {
    reply.status(200).send({ ServerOnline: true });
  });
  
  server.ready().then(() =&gt; {
    server.io.on(&quot;connection&quot;, (socket) =&gt; {
      console.log(&quot;user connected&quot; + socket.id);
      socket.on(&quot;message&quot;, (data) =&gt; {
        console.log(data);
      });
    });
  });
  </code></pre>
  <p>Here is the front end code:</p>
  <pre><code>import &quot;./App.css&quot;;
  import { io } from &quot;socket.io-client&quot;;
  
  function App() {
    const sendData = () =&gt; {
      const socket = io(&quot;http://localhost:5000&quot;);
      socket.on(&quot;connection&quot;);
      const sendMessage = () =&gt; {
        socket.emit(&quot;message&quot;, &quot;hey it worked!&quot;);
      };
      sendMessage();
    };
  
    return (
      &lt;div className=&quot;app-container&quot;&gt;
        &lt;h1&gt;Socket.IO&lt;/h1&gt;
        &lt;button onClick={sendData}&gt;Send&lt;/button&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>
  <p>I'm not sure why I'm getting these cors Errors I think it has something to do with <code>fastify-socket.io</code></p>