Skip to content

Commit 45fc26f

Browse files
committed
Add 404 example
1 parent b5218cd commit 45fc26f

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

examples/404.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
*
3+
* Install:
4+
* npm install browser-sync
5+
*
6+
* Run:
7+
* node <yourfile.js>
8+
*
9+
* This example will redirect all 404 requests to a
10+
* custom 404.html page
11+
*
12+
*/
13+
14+
"use strict";
15+
16+
var browserSync = require("browser-sync").create();
17+
18+
browserSync.init({
19+
files: ["app/css/*.css"],
20+
server: {
21+
baseDir: "app"
22+
}
23+
}, function (err, bs) {
24+
bs.addMiddleware("*", function (req, res) {
25+
res.writeHead(302, {
26+
"location": "404.html"
27+
});
28+
res.end('Redirecting!');
29+
});
30+
});

0 commit comments

Comments
 (0)