From 10dfd892b4010cff35b7e2fbb6677a9607e1b738 Mon Sep 17 00:00:00 2001 From: Buns Shar Date: Sat, 15 Apr 2017 08:21:29 +0530 Subject: [PATCH] Ensure proxy url starts with `http://` or `https://` (#1890) --- packages/react-scripts/scripts/start.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 936214e50b..05ed73d77f 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -188,6 +188,14 @@ function addMiddleware(devServer) { console.log(chalk.red('Instead, the type of "proxy" was "' + typeof proxy + '".')); console.log(chalk.red('Either remove "proxy" from package.json, or make it a string.')); process.exit(1); + // Test that proxy url specified starts with http:// or https:// + } else if (!/^http(s)?:\/\//.test(proxy)) { + console.log( + chalk.red( + 'When "proxy" is specified in package.json it must start with either http:// or https://' + ) + ); + process.exit(1); } // Otherwise, if proxy is specified, we will let it handle any request.