Skip to content

Commit

Permalink
feat(pluginsdk): Allow overriding proxy ports in deck dev-proxy (#10115)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
3 people authored Jun 26, 2024
1 parent 2f7f8de commit 3fe8402
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/pluginsdk/scripts/dev-proxy/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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}/`);

0 comments on commit 3fe8402

Please sign in to comment.