From f0145348ad5a839e6a3bf02f448a1921004a2c28 Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 1 Apr 2024 21:52:31 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=9A=A6forward=20`HOST`=20to=20dev=20s?= =?UTF-8?q?erver=20as=20`CONTENT=5FCDN=5FHOST`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/myst-cli/src/build/site/start.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/myst-cli/src/build/site/start.ts b/packages/myst-cli/src/build/site/start.ts index c9a219263..3d6766912 100644 --- a/packages/myst-cli/src/build/site/start.ts +++ b/packages/myst-cli/src/build/site/start.ts @@ -142,6 +142,7 @@ export async function startServer( cwd: mystTemplate.templatePath, env: { ...process.env, + CONTENT_CDN_HOST: process.env.HOST ?? 'localhost', CONTENT_CDN_PORT: String(server.port), PORT: String(port), MODE: opts.buildStatic ? 'static' : 'app', From 3e2d697eff698c166169a4fb1766a09f262dd01b Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 1 Apr 2024 22:09:02 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=AA=B5=20update=20logging=20to=20refl?= =?UTF-8?q?ect=20host?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/myst-cli/src/build/site/logger.ts | 6 +++++- packages/myst-cli/src/build/site/start.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/myst-cli/src/build/site/logger.ts b/packages/myst-cli/src/build/site/logger.ts index 763ea5629..7cedb8ada 100644 --- a/packages/myst-cli/src/build/site/logger.ts +++ b/packages/myst-cli/src/build/site/logger.ts @@ -10,8 +10,12 @@ export function createServerLogger(session: ISession, ready: () => void): Logger if (line.includes('File changed: app/content')) return; // This is shown elsewhere if (line.includes('started at http://')) { const [, ipAndPort] = line.split('http://'); + const host = + process.env.HOST && process.env.HOST.startsWith('http') + ? new URL(process.env.HOST).hostname + : process.env.HOST ?? 'localhost'; const port = ipAndPort.split(':')[1].replace(/[^0-9]/g, ''); - const local = `http://localhost:${port}`; + const local = `http://${host}:${port}`; ready(); session.log.info( `\nšŸ”Œ Server started on port ${port}! šŸ„³ šŸŽ‰\n\n\n\tšŸ‘‰ ${chalk.green(local)} šŸ‘ˆ\n\n`, diff --git a/packages/myst-cli/src/build/site/start.ts b/packages/myst-cli/src/build/site/start.ts index 3d6766912..9abc1d131 100644 --- a/packages/myst-cli/src/build/site/start.ts +++ b/packages/myst-cli/src/build/site/start.ts @@ -123,7 +123,7 @@ export async function startServer( }); } if (opts.headless) { - const local = chalk.green(`http://localhost:${server.port}`); + const local = chalk.green(`http://${process.env.HOST ?? 'localhost'}:${server.port}`); session.log.info( `\nšŸ”Œ Content server started on port ${server.port}! šŸ„³ šŸŽ‰\n\n\n\tšŸ‘‰ ${local} šŸ‘ˆ\n\n`, ); From 461987b5e6a66e68afec502fd80ba569bc0753fc Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 1 Apr 2024 22:20:19 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=97changeset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/sharp-wasps-tap.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sharp-wasps-tap.md diff --git a/.changeset/sharp-wasps-tap.md b/.changeset/sharp-wasps-tap.md new file mode 100644 index 000000000..fec8b2410 --- /dev/null +++ b/.changeset/sharp-wasps-tap.md @@ -0,0 +1,5 @@ +--- +'myst-cli': patch +--- + +Set `CONTENT_CDN_HOST` when `HOST` environment variable is specified and default to `localhost` otherwise. Also improve log messages when `HOST` is provided.