dev_server_port.ts

view source

Declarations
#

3 declarations

check_dev_server_port
#

dev_server_port.ts view source

(options: DevServerPortOptions): string | null import {check_dev_server_port} from '@fuzdev/zzz/dev_server_port.js';

Checks that the dev UI calls the dev server that serves it.

The UI sends its HTTP RPC calls and file bytes to http://localhost:<PUBLIC_ZZZ_SERVER_PORT> when the variable is set, so a value naming another port sends them to whatever process listens there. Login and the WebSocket don't use the variable and keep working, which makes the misroute easy to miss — so the dev server refuses to start. Unset or blank is fine: the UI then calls the page's own origin.

vite.config.ts runs this when the dev server starts.

options

returns

string | null

the error to fail the dev server with, or null when the value is consistent

DEV_SERVER_PORT_VAR
#

DevServerPortOptions
#

dev_server_port.ts view source

DevServerPortOptions import type {DevServerPortOptions} from '@fuzdev/zzz/dev_server_port.js';

loaded

The value of DEV_SERVER_PORT_VAR as Vite loaded it, undefined when unset.

type string | undefined

port

The port the dev server is about to serve on.

type number

from_process_env

Whether the loaded value came from the process environment rather than an env file.

type boolean

mode

The Vite mode, which names the env file (.env.<mode>).

type string