Fix serving directly from paths under root
This commit is contained in:
parent
2103334a21
commit
ab6aabd8e9
10
serve.js
10
serve.js
|
@ -1,4 +1,5 @@
|
|||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var process = require('process');
|
||||
var express = require('express');
|
||||
var webpack = require('webpack');
|
||||
|
@ -16,7 +17,14 @@ app.use(require('webpack-dev-middleware')(compiler, {
|
|||
app.use(require('webpack-hot-middleware')(compiler));
|
||||
|
||||
app.get('*', function(req, res) {
|
||||
res.sendFile(path.join(__dirname, req.path));
|
||||
var _path = path.join(__dirname, req.path);
|
||||
fs.access(_path, fs.constants.R_OK, err => {
|
||||
if (!err) {
|
||||
res.sendFile(_path);
|
||||
} else {
|
||||
res.sendFile(path.join(__dirname, '/index.html'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var port = process.env.MANAGER_PORT || 3000;
|
||||
|
|
Loading…
Reference in New Issue
Block a user