How to fix this CORS issue in socket.io?

I am trying to connect to a remote server with socket.io, but I am having some problems. I am getting this error: The value of the Access-Control-Allow-Credentials header in the response is ’ ’ which must be ‘true’ when the request’s credentials mode is ‘include’

OK, so here is the code:

Server

var server = require('http').createServer();

const io = require("socket.io")(server, {
  cors: {
    origin: "my URL",
    methods: ["GET", "POST"],
    credentials: false
  }
});


io.sockets.on('connection', function(socket) {
    console.log("Client has connected!");
});

console.log ('Server started.');
server.listen(3000);

Here is the client code:

var socket = io.connect("https://persistent-gentle-banon.glitch.me", {
  withCredentials: false
});

How can I solve this and get it to connect?

Thanks for any help!

Hey there @lando19! To properly answer your question, it’s important to know from which domain you are calling the final code snippet from. Let’s say I have a WebSocket server (or any web resource for that matter) running on mysite.com, CORS ensures you cannot just use fetch('https://mysite.com/') if you are currently on yoursite.com. So, where (most interestingly: on what domain) do you exactly implement the client code? Also, you can read more about what CORS means here.