@@ -5,25 +5,16 @@ import compression from 'compression';
55import Api from './api' ;
66import cookieParser from 'cookie-parser' ;
77import ReactRenderer from './renderer' ;
8+ import { httpsRedirect } from 'middleware' ;
89
910const env = process . env . NODE_ENV || 'development' ;
10- let app = new express ( ) ;
11+ const app = new express ( ) ;
1112
1213// Secure with helmet
1314app . use ( helmet ( ) ) ;
1415
15- /* Ensures SSL in used in production. To use, uncomment the below.
16- app.use(function (req, res, next) {
17- var sslUrl;
18-
19- if (env === 'production' && req.headers['x-forwarded-proto'] !== 'https') {
20- sslUrl = [process.env.APPLICATION_BASE_URL, req.url].join('');
21- return res.redirect(sslUrl);
22- }
23-
24- return next();
25- });
26- */
16+ // Ensures SSL in used in production.
17+ app . use ( httpsRedirect ( { enabled : env === 'production' } ) ) ;
2718
2819// parse cookies!
2920app . use ( cookieParser ( ) ) ;
@@ -32,14 +23,18 @@ app.use(cookieParser());
3223app . use ( compression ( ) ) ;
3324
3425// Add middleware to serve up all static files
35- app . use ( '/assets' ,
26+ app . use (
27+ '/assets' ,
3628 express . static ( path . join ( __dirname , '../' + process . env . PUBLIC_OUTPUT_PATH ) ) ,
3729 express . static ( path . join ( __dirname , '../common/images' ) ) ,
3830 express . static ( path . join ( __dirname , '../common/fonts' ) )
3931) ;
4032
4133// handle browsers requesting favicon
42- app . use ( '/favicon.ico' , express . static ( path . join ( __dirname , '../common/images/favicon/favicon.ico' ) ) ) ;
34+ app . use (
35+ '/favicon.ico' ,
36+ express . static ( path . join ( __dirname , '../common/images/favicon/favicon.ico' ) )
37+ ) ;
4338
4439// Mount the REST API
4540app . use ( '/api' , Api ) ;
0 commit comments