title: CORS blocking localhost request despite being explicitly allowed
body: <p>I have a NodeJS (Express + Socket.io) server running backend with a React frontend. My React is running on localhost:3000 whereas my backend runs on port 4000. I've explicitly allowed CORS requests to be made to my Socket.IO server:</p>
  <pre><code>const express = require('express')
  const { createServer } = require(&quot;http&quot;);
  const cors = require('cors')
  const { Server } = require(&quot;socket.io&quot;);
  const app = express();
  const httpServer = createServer(app);
  const {errorHandler} = require('./middleware/errorMiddleware')
  const {connectDB} = require('./config/db');
  const port = process.env.PORT || 4000
  require('dotenv').config()
  
  connectDB()
  
  //TEST logic for creating local list
  const usersWaiting = []
  
  //initialize Socket.io server
  const io = new Server(httpServer, {
      cors: {origin: &quot;http://localhost:3000&quot;, methods: [&quot;GET&quot;]}
  });
  
  //configure everything, define routes
  app.use(express.json())
  app.use(express.urlencoded({extended: false}))
  app.use('/user', require('./routes/userRoute'))
  app.use(errorHandler)
   
  //set 404
  app.use((req, res, next) =&gt; {
      res.status(404).send('Not found.')
  })
  
  //start the listening
  httpServer.listen(port, () =&gt; {console.log(`Server started on port ${port}.`)})
  </code></pre>
  <p>And in my React frontend I do a simple <strong>async onClick</strong> with this in it to test:</p>
  <pre><code>console.log(await fetch('http://localhost:4000/user'))
  </code></pre>
  <p>And the error I receive:</p>
  <p><strong>Access to fetch at 'http://localhost:4000/user' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.</strong></p>
  <p>Now I know, I know, this question's been asked a few times. However I've read 15 answers and implemented literally every single one of your advices. Nothing works.</p>
  <p>I feel like I'm going crazy - please help!</p>