Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed bug

* replace url of http request when static serving required
* add error handling for static serving
  • Loading branch information...
commit 6eb38ea4f352290fc803382f07f5d061c076d51c 1 parent 5583da5
@zentooo authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/http-proxy-selective.js
View
11 lib/http-proxy-selective.js
@@ -28,7 +28,16 @@ function handle(req, res) {
staticServer = (statics[url.host]) ? statics[url.host][trimslash(splat.dirname)] : null;
if ( staticServer ) {
- staticServer.serve(req, res);
+ req.url = splat.filename;
+
+ staticServer.serve(req, res, function(err, result) {
+ if (err) {
+ util.error("Error serving " + staticServer.root + splat.filename + " - " + err.message);
+
+ res.writeHead(err.status, err.headers);
+ res.end();
+ }
+ });
console.log("selective: ".yellow + "replaced " + url.href.red + " with local file: " + (staticServer.root + splat.filename).green);
}
else {
Please sign in to comment.
Something went wrong with that request. Please try again.