From 0e4123fe98dae949db5e1d7380a7d53db9eb538f Mon Sep 17 00:00:00 2001 From: Chord Date: Mon, 30 Dec 2019 15:50:01 -0500 Subject: [PATCH] Add apache logging + trust proxy to prod --- index.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 264c7d4..b52a680 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,13 @@ const app = express(); // apache logging on web requests if (MODE !== 'production') { app.use(morgan('dev')); +} else { + app.use(morgan('combined')); +} + +if (process.env.TRUST_PROXY) { + console.log("Trusting proxy") + app.set('trust proxy', 'loopback') } // TODO: recaptcha @@ -63,18 +70,6 @@ if (MODE !== 'production') { // All API requests have a session. Other requests are static app.use("/api", sessionMiddleware, api); - /*if (MODE === 'development') { - const webpack = await import('webpack') - const middleware = await import('webpack-dev-middleware') - const config = await import('./webpack.config.cjs') - const hot_webpack = await import('webpack-hot-middleware') - const hot_server_webpack = await import('webpack-hot-server-middleware') - const compiler = webpack.default(config.default) - app.use(middleware.default(compiler)) - app.use(hot_webpack.default(compiler)) - app.use(hot_server_webpack.default(compiler)) - }*/ - // TODO: inject csrf token into meta of index.html app.use(express.static('public'));