Redirect to .html files, #25
This commit is contained in:
parent
b546e6377c
commit
3626606df5
1 changed files with 13 additions and 0 deletions
13
server.js
13
server.js
|
@ -2,6 +2,8 @@
|
|||
|
||||
// env variables
|
||||
require('dotenv').config();
|
||||
// fs
|
||||
var fs = require('fs');
|
||||
// Async
|
||||
var async = require("async");
|
||||
// Express etc
|
||||
|
@ -84,6 +86,17 @@ app.get('/github-feed', function(req, res) {
|
|||
|
||||
});
|
||||
|
||||
app.get('/*', function(req, res) {
|
||||
|
||||
if(fs.existsSync(__dirname + "/.vuepress/dist" + req.path + ".html")) {
|
||||
res.redirect(req.path + ".html");
|
||||
} else {
|
||||
res.status(404);
|
||||
res.send('Not found');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var port = process.env.PORT || 8080;
|
||||
app.listen(port);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue