diff --git a/apps/dev-playground/.env.dist b/apps/dev-playground/.env.dist index 2d3a28f0..fee1b85e 100644 --- a/apps/dev-playground/.env.dist +++ b/apps/dev-playground/.env.dist @@ -1,5 +1,4 @@ DATABRICKS_HOST= -DATABRICKS_APP_PORT=8001 DATABRICKS_WAREHOUSE_ID= DATABRICKS_WORKSPACE_ID= NODE_ENV='development' diff --git a/packages/appkit/src/plugins/server/index.ts b/packages/appkit/src/plugins/server/index.ts index 40cf01e0..ac1c0a6e 100644 --- a/packages/appkit/src/plugins/server/index.ts +++ b/packages/appkit/src/plugins/server/index.ts @@ -37,7 +37,9 @@ export class ServerPlugin extends Plugin { public static DEFAULT_CONFIG = { autoStart: true, host: process.env.FLASK_RUN_HOST || "0.0.0.0", - port: Number(process.env.DATABRICKS_APP_PORT) || 8000, + port: + Number(process.env.DATABRICKS_APP_PORT) || + (process.env.NODE_ENV === "development" ? 0 : 8000), }; /** Plugin manifest declaring metadata and resource requirements */ @@ -257,7 +259,11 @@ export class ServerPlugin extends Plugin { private logStartupInfo() { const isDev = process.env.NODE_ENV === "development"; const hasExplicitStaticPath = this.config.staticPath !== undefined; - const port = this.config.port ?? ServerPlugin.DEFAULT_CONFIG.port; + const address = this.server?.address(); + const port = + typeof address === "object" && address?.port + ? address.port + : (this.config.port ?? ServerPlugin.DEFAULT_CONFIG.port); const host = this.config.host ?? ServerPlugin.DEFAULT_CONFIG.host; logger.info("Server running on http://%s:%d", host, port);