Skip to content

Instantly share code, notes, and snippets.

@jonnsl
Created February 23, 2013 22:15
Show Gist options
  • Save jonnsl/5021596 to your computer and use it in GitHub Desktop.
Save jonnsl/5021596 to your computer and use it in GitHub Desktop.
How to reproduce issue 991 - socket.io
<!doctype html5>
<html>
<head>
<title></title>
<script src="https://rawgithub.com/LearnBoost/socket.io-client/0.9/dist/socket.io.min.js"></script>
<script>
var socket = io.connect('http://localhost');
</script>
<body>
var express = require('express')
, http = require('http')
, path = require('path')
, fs = require('fs');
var www = express();
var server = http.createServer(www);
require('socket.io').listen(server);
var index = fs.readFileSync('index.html').toString();
www.use(function(req, res){
res.send(index);
});
// this work
//server.listen(3000);
// this does not work
var app = express();
app.use(express.vhost('localhost', server));
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment