Skip to content

Instantly share code, notes, and snippets.

@bebraw
Created February 19, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bebraw/40c52b65ae5a1100c53f to your computer and use it in GitHub Desktop.
Save bebraw/40c52b65ae5a1100c53f to your computer and use it in GitHub Desktop.
'use strict';
var express = require('express');
var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var config = require('./config/webpack.config');
main();
function main() {
var port = 4000;
var ip = '0.0.0.0';
var app = express();
app.use(webpackDevMiddleware(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
stats: {
color: true
},
}));
// XXX: matches too much? how about socket.io?
app.get('/*', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
app.listen(port, ip, function(err) {
if(err) {
return console.error(err);
}
console.log('Listening at ' + ip + ':' + port);
});
}
@bebraw
Copy link
Author

bebraw commented Feb 19, 2015

The problem is that this yields XMLHttpRequest cannot load http://0.0.0.0:4000/socket.io/1/?t=1424354024912. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4000' is therefore not allowed access. so hot loading doesn't work. Maybe /* matches a bit too much?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment