From 3fe840255acd53f8c8f386d20b13053e7844afc3 Mon Sep 17 00:00:00 2001 From: Dylan Watson Date: Wed, 26 Jun 2024 19:17:53 +0800 Subject: [PATCH] feat(pluginsdk): Allow overriding proxy ports in deck dev-proxy (#10115) * feat(pluginsdk): Allow overriding proxy ports in deck dev-proxy * Run prettier --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Dylan Watson --- packages/pluginsdk/scripts/dev-proxy/server.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/pluginsdk/scripts/dev-proxy/server.js b/packages/pluginsdk/scripts/dev-proxy/server.js index 9c06a814eeb..7d3e4ca69db 100755 --- a/packages/pluginsdk/scripts/dev-proxy/server.js +++ b/packages/pluginsdk/scripts/dev-proxy/server.js @@ -26,6 +26,11 @@ const packageJson = JSON.parse(fs.readFileSync('package.json', 'UTF-8')); const DEV_PROXY_HOST = process.env.DEV_PROXY_HOST || (packageJson.devProxy && packageJson.devProxy.host); +const DEV_PROXY_HTTP_PORT = + parseInt(process.env.DEV_PROXY_HTTP_PORT || (packageJson.devProxy && packageJson.devProxy.httpPort)) || 9000; +const DEV_PROXY_HTTPS_PORT = + parseInt(process.env.DEV_PROXY_HTTPS_PORT || (packageJson.devProxy && packageJson.devProxy.httpsPort)) || 9443; + if (!DEV_PROXY_HOST) { console.error(); console.error(); @@ -94,7 +99,7 @@ app.use('/livereload.js', require('./livereload')); app.use('/', createProxyMiddleware({ target: DEV_PROXY_HOST, changeOrigin: true })); // http -http.createServer(app).listen(9000); +http.createServer(app).listen(DEV_PROXY_HTTP_PORT); // https https @@ -105,7 +110,7 @@ https }, app, ) - .listen(9443); + .listen(DEV_PROXY_HTTPS_PORT); -console.log(`Server started on http://localhost:9000/`); -console.log(`Server started on https://localhost:9443/`); +console.log(`Server started on http://localhost:${DEV_PROXY_HTTP_PORT}/`); +console.log(`Server started on https://localhost:${DEV_PROXY_HTTPS_PORT}/`);