Simple socket.io chat with repl.it authentication
On a whim I made a relatively simple socket.io chat - except using repl.it's "oauth" authentication system.
How it works
Client sends messages to server, which relays them, along with the username of the sender, to the other clients. Server joins and leaves are also announced.
The server checks for the "x-replit-user-name" header when you request the file. By default this header doesn't exist, meaning that you will appear as a "Guest".
When you click the login button, it creates a repl.it login popup. When this is completed, a cookie is created with your repl.it id, as well as the "x-replit-user-name" HTTP header.
The client then reloads. Now the server checks for the username header again, and finds it! it will now use this username inside the chat as your nickname.
a cookie is created with your repl.it id
it's not your replit id
repl.it's "oauth" authentication system.
it's not oauth