Multiplayer Snake Game | JavaScript & Socket.io
Why Stack Overflow recommends it
Stack Overflow users link it when they follow the tutorial's Socket.io setup and hit a CORS error around the 15 minute mark.
Recommended by 1 people across 1 different months, 2021 to 2022.
What it is
A 78-minute Traversy Media tutorial, presented by Adrian of Hungry Turtle Code, that builds a multiplayer snake game with a Node.js server and Socket.io. It covers canvas drawing, moving game state to the server, a game loop, and letting a second player join a room.
What people said
Recommends Anthony · 2021-06 · Stack Overflow · on “Node server with socket.io wont establish connection”
I just recently started an online tutorial on how to make a multiplayer snake.io game with Node js and socket.io. [this video] Things went pretty smooth setting things up for the client side, but once I tried to establish a socket,(15:20 in video), I get errors in the client side browser chrome console, trying to establish a communication. At first I received an error as follows 127.0.0.1/:1 Access to XMLHttpRequest at ' [LINK] ' from origin ' [LINK] ' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. I then did some research on what CORS is, and to my understanding it is like a security protocol which restricts connections between diff
Cites Anthony · 2021-06 · Stack Overflow · on “Failure to communicate with node.js server”
I have been following a tutorial on youtube , [this video] . This tutorial shows how to setup up a basic server with socket.io and lets two people play the classic snake game. After trying to setup communication with the server and client, I have received errors in the developer console on the client side. The first error I received was 127.0.0.1/:1 Access to XMLHttpRequest at ' [LINK] ' from origin ' [LINK] ' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. I then asked for help here and recieved good feedback about handling a cors error. So I then searched up how to handle cors with socket.io and modified my code to the following in
Cites Monochromatic · 2021-12 · Stack Overflow · on “socket.io "Cross-Origin request Blocked" error”
So, I'm trying to follow along this [this video] 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=" [LINK] "></script> <script src="index.js"></script> </html> root/frontend/index.js const socket=io(' [LINK] '); 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
Cites amazegames · 2022-08 · Stack Overflow · on “How do I fix a CORS error that I'm getting when trying to make a multiplayer snake game”
can somebody help me fix this error: "Access to XMLHttpRequest at ' [LINK] ' from origin ' [LINK] ' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value ' [LINK] ' that is not equal to the supplied origin." I have been following this video on how to make a snake game:" [this video] ", got to around 15:00, then can't proceed because of the error I tried copying some of the code from the socket.io website on how to fix CORS, but it does not work [LINK] was running index.html from the live server extension for vscode on microsoft edge server.js: const httpServer = require("http").createServer(); const i