So, I'm trying to follow along this tutorial and right off the bat I can't get it to work. First off, these are my files:
root/frontend/index.html
<html>
[...]some static page[...]
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js"></script>
<script src="index.js"></script>
</html>
root/frontend/index.js
const socket=io('http://localhost:3000');
socket.on('init', handleInit);
function handleInit(msg) {
console.log(msg);
}
root/server/server.js
const io=require('socket.io')();
io.on('connection', client =>{
client.emit('init', {data:'hello'});
});
io.listen(3000);
What he does next is running "npx live-server" in the frontend folder (which I also do). And also, run "yarn add socket.io" in the server folder and then run "npx nodemon server.js" and it's supposed to work. But doing those exact steps I get the errors: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3000/socket.io/?EIO=3&transport=polling&t=NsGvIgN. (Reason: CORS request did not succeed)"
and
"GET http://localhost:3000/socket.io/?EIO=3&transport=polling&t=NsGvO1Z"