onedayitwillmake/RealtimeMultiplayerNodeJs — Issue #2: Serving static files / obeying the Same Origin policy for websockets
Author: nickretallack
Created: 2011-11-15 08:04:39+00:00
State: open

The instructions in the readme are very vague.

"run the server and brows to "/DemoHelloWorld.html"

On localhost? What port? I can just open the file DemoHelloWorld.html, but then it will be on a different origin from the websockets, causing it to print this:

```
14 Nov 23:57:57 - Initializing client with transport "websocket"
14 Nov 23:57:57 - WebSocket connection invalid or Origin not verified
14 Nov 23:58:02 - Initializing client with transport "xhr-polling"
14 Nov 23:58:02 - Client 03701277635991573 connected
1 joined the game!
```

If you want to use websockets, you have to be on the same origin, right? So you should have your server serve up this static file. And you should be clear about where your server is serving it to. It does not print out the client port to the terminal, and it took me a bit of hunting to find where that is even set.