Skip to content

Commit be15d70

Browse files
committed
fix: keep vite UI reachable over Tailscale (PM2 launch + host binding)
- PM2 now launches vite from the repo-root bin (absolute path) with interpreter: node, fixing an ERR_MODULE_NOT_FOUND crash loop that took port 6373 down whenever npm hoisted vite out of the client workspace. - vite binds 0.0.0.0 and de-duplicates the allowedHosts key (`.ts.net`), so the UI is reachable across the tailnet over HTTP, or HTTPS when fronted by `tailscale serve`.
1 parent 3e059bc commit be15d70

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

.changelog/NEXT.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
- Provider comparison cards no longer emit an invalid nested-`<button>` HTML warning under React 19 (the card header is now a `role="button"` element, keeping click and keyboard toggling).
1414
- SQLite driver is now loaded lazily so the server can start and serve JSON-backed data even when the native binding is unavailable.
15-
- Dev server accepts requests from any host (`allowedHosts: true`) so the UI is reachable via Tailscale hostnames.
15+
- Dev server binds all interfaces and accepts Tailscale `*.ts.net` hostnames, so the UI is reachable across the tailnet (over plain HTTP, or HTTPS when fronted by `tailscale serve`).
16+
- PM2 launches the vite UI via the repo-root bin path with an explicit node interpreter, fixing a crash loop (`ERR_MODULE_NOT_FOUND`) that left port 6373 down when npm hoisted vite out of the client workspace.
1617

1718
## Added
1819

client/vite.config.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import tailwindcss from '@tailwindcss/vite';
55
export default defineConfig({
66
plugins: [react(), tailwindcss()],
77
server: {
8-
allowedHosts: true,
8+
host: '0.0.0.0',
99
port: 6373,
10-
// Allow access over Tailscale MagicDNS (https://<node>.<tailnet>.ts.net/)
11-
// fronted by `tailscale serve`. A leading dot matches the domain and all
12-
// subdomains, so every node name in the tailnet is accepted.
10+
// Allow access over Tailscale MagicDNS (http://<node>.<tailnet>.ts.net:6373/,
11+
// or https://<node>.<tailnet>.ts.net/ when fronted by `tailscale serve`).
12+
// A leading dot matches the domain and all subdomains, so every node name
13+
// in the tailnet is accepted.
1314
allowedHosts: ['.ts.net'],
1415
proxy: {
1516
'/api': {

ecosystem.config.cjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ module.exports = {
3030
},
3131
{
3232
name: 'sparsetree-ui',
33-
script: 'node_modules/.bin/vite',
33+
// vite is hoisted to the repo-root node_modules in this npm workspace, so
34+
// reference the root bin via an absolute path (the client-local .bin/vite
35+
// may not exist). interpreter: 'node' so pm2 execs the bin instead of
36+
// trying to import() it as an ESM module.
37+
script: `${__dirname}/node_modules/.bin/vite`,
3438
cwd: `${__dirname}/client`,
39+
interpreter: 'node',
3540
args: `--host 0.0.0.0 --port ${PORTS.UI}`,
3641
env: {
3742
NODE_ENV: 'development',

0 commit comments

Comments
 (0)