Skip to content

Instantly share code, notes, and snippets.



Created Feb 19, 2015
What would you like to do?
'use strict';
var express = require('express');
var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var config = require('./config/webpack.config');
function main() {
var port = 4000;
var ip = '';
var app = express();
app.use(webpackDevMiddleware(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
stats: {
color: true
// XXX: matches too much? how about
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);

This comment has been minimized.

Copy link
Owner Author

@bebraw bebraw commented Feb 19, 2015

The problem is that this yields XMLHttpRequest cannot load 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