hard coded /public folder
This commit is contained in:
parent
05822c393c
commit
8c50fc8b83
1 changed files with 7 additions and 10 deletions
17
index.js
17
index.js
|
@ -29,21 +29,18 @@ function Server () {
|
||||||
app.enable('trust proxy');
|
app.enable('trust proxy');
|
||||||
|
|
||||||
/* add middleware */
|
/* add middleware */
|
||||||
|
|
||||||
// set HTTP headers to protect against well-known web vulnerabilties
|
// set HTTP headers to protect against well-known web vulnerabilties
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
|
|
||||||
// 'express.static' to serve static files from public directory
|
// 'express.static' to serve static files from public directory
|
||||||
if (siteConfig.routes.publicFolder) {
|
const publicPath = Path.resolve(process.cwd(), 'public');
|
||||||
// take in a different public folder, so it can serve it's own bundle if needed
|
app.use(express.static(publicPath));
|
||||||
const publicFolder = Path.resolve(process.cwd(), siteConfig.routes.publicFolder);
|
logger.info(`serving static files from default static path at ${publicPath}.`);
|
||||||
app.use(express.static(publicFolder));
|
|
||||||
logger.info('serving static files from custom path:', publicFolder);
|
|
||||||
} else {
|
|
||||||
const publicPath = Path.resolve(process.cwd(), 'public');
|
|
||||||
app.use(express.static(publicPath));
|
|
||||||
logger.warn(`serving static files from default static path at ${publicPath}. Please specify a path in your config/siteConfig.js file`);
|
|
||||||
};
|
|
||||||
// 'body parser' for parsing application/json
|
// 'body parser' for parsing application/json
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
// 'body parser' for parsing application/x-www-form-urlencoded
|
// 'body parser' for parsing application/x-www-form-urlencoded
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue