|
10 | 10 | // @remove-on-eject-end
|
11 | 11 | 'use strict';
|
12 | 12 |
|
| 13 | +// ZEAL: add fs for ssl key and cert loading |
| 14 | +const fs = require('fs'); |
13 | 15 | const errorOverlayMiddleware = require('react-error-overlay/middleware');
|
14 | 16 | const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
|
15 | 17 | const config = require('./webpack.config.dev');
|
16 | 18 | const paths = require('./paths');
|
17 | 19 |
|
18 |
| -const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'; |
19 | 20 | const host = process.env.HOST || '0.0.0.0';
|
| 21 | +// ZEAL: ssl file loading |
| 22 | +const readSslFile = function(path) { |
| 23 | + try { |
| 24 | + return fs.readFileSync(path); |
| 25 | + } catch (err) { |
| 26 | + console.log('Unable to parse SSL path - ' + path); |
| 27 | + process.exit(1); |
| 28 | + } |
| 29 | +}; |
| 30 | +// ZEAL: handle ssl key and certs when running http |
| 31 | +const https = (function(https, key_path, cert_path) { |
| 32 | + if (https === 'true') { |
| 33 | + if (key_path && cert_path) { |
| 34 | + return { key: readSslFile(key_path), cert: readSslFile(cert_path) }; |
| 35 | + } else { |
| 36 | + return true; |
| 37 | + } |
| 38 | + } else { |
| 39 | + return false; |
| 40 | + } |
| 41 | +})(process.env.HTTPS, process.env.SSL_KEY_PATH, process.env.SSL_CERT_PATH); |
20 | 42 |
|
21 | 43 | module.exports = function(proxy, allowedHost) {
|
22 | 44 | return {
|
@@ -78,7 +100,8 @@ module.exports = function(proxy, allowedHost) {
|
78 | 100 | ignored: /node_modules/,
|
79 | 101 | },
|
80 | 102 | // Enable HTTPS if the HTTPS environment variable is set to 'true'
|
81 |
| - https: protocol === 'https', |
| 103 | + // ZEAL: load https from functions up above |
| 104 | + https: https, |
82 | 105 | host: host,
|
83 | 106 | overlay: false,
|
84 | 107 | historyApiFallback: {
|
|
0 commit comments