Skip to content

Commit de7cf70

Browse files
committedNov 9, 2019
Merge branch 'master' into update-travis-node-versions
2 parents 5dcf680 + 1755478 commit de7cf70

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed
 

‎README.md

+10
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ Using `npx` you can run the script without installing it first:
8282
- `index.html` will be served as the default file to any directory requests.
8383
- `404.html` will be served if a file is not found. This can be used for Single-Page App (SPA) hosting to serve the entry page.
8484

85+
## Catch-all redirect
86+
87+
To implement a catch-all redirect, use the index page itself as the proxy with:
88+
89+
```
90+
http-server --proxy http://localhost:8080?
91+
```
92+
93+
Note the `?` at the end of the proxy URL. Thanks to [@houston3](https://github.com/houston3) for this clever hack!
94+
8595
# Development
8696

8797
Checkout this repository locally, then:

‎package-lock.json

+25-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"devDependencies": {
8585
"common-style": "^3.0.0",
8686
"request": "^2.88.0",
87-
"vows": "~0.7.0"
87+
"vows": "~0.8.3"
8888
},
8989
"bugs": {
9090
"url": "https://github.com/nodeapps/http-server/issues"

‎test/http-server-test.js

+15
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ vows.describe('http-server').addBatch({
125125
assert.equal(body.trim(), file.trim());
126126
}
127127
}
128+
},
129+
teardown: function (proxyServer) {
130+
proxyServer.close();
128131
}
132+
},
133+
teardown: function (server) {
134+
server.close();
129135
}
130136
},
131137
'When cors is enabled': {
@@ -156,6 +162,9 @@ vows.describe('http-server').addBatch({
156162
'response Access-Control-Allow-Headers should contain X-Test': function (err, res) {
157163
assert.ok(res.headers['access-control-allow-headers'].split(/\s*,\s*/g).indexOf('X-Test') >= 0, 204);
158164
}
165+
},
166+
teardown: function (server) {
167+
server.close();
159168
}
160169
},
161170
'When gzip and brotli compression is enabled and a compressed file is available': {
@@ -209,6 +218,9 @@ vows.describe('http-server').addBatch({
209218
assert.equal(res.statusCode, 200);
210219
assert.equal(res.headers['content-encoding'], 'br');
211220
}
221+
},
222+
teardown: function (server) {
223+
server.close();
212224
}
213225
},
214226
'When http-server is listening on 8083 with username "good_username" and password "good_password"': {
@@ -341,6 +353,9 @@ vows.describe('http-server').addBatch({
341353
assert.equal(body.trim(), file.trim());
342354
}
343355
}
356+
},
357+
teardown: function (server) {
358+
server.close();
344359
}
345360
}
346361
}).export(module);

0 commit comments

Comments
 (0)