Skip to content

Instantly share code, notes, and snippets.

@tivac
Last active December 15, 2015 21:28
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 tivac/bcf81a050e154b3ae02d to your computer and use it in GitHub Desktop.
Save tivac/bcf81a050e154b3ae02d to your computer and use it in GitHub Desktop.
Dumb static SPA server
"use strict";
var path = require("path"),
server = require("connect")(),
ecstatic = require("ecstatic")(process.cwd(), {
cache : 0,
handleError : false
});
server.use(function(req, res, next) {
console.log(req.url);
next();
});
server.use(ecstatic);
// SPA support
server.use(function(req, res, next) {
if(path.extname(req.url)) {
res.code = 404;
return next("Unknown file");
}
req.url = "/";
ecstatic(req, res, next);
});
server.listen(9966);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment