Use Tailscale host for HotView HMR

This commit is contained in:
2026-07-15 17:34:21 -05:00
parent c438f62e52
commit ddd7e869ef
3 changed files with 12 additions and 4 deletions
+9 -1
View File
@@ -1,5 +1,13 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { networkInterfaces } from 'node:os'
function tailscaleHost() {
const addresses = networkInterfaces().Tailscale ?? []
return addresses.find((address) => address.family === 'IPv4' && !address.internal)?.address
}
const hmrHost = process.env.VITE_HMR_HOST?.trim() || tailscaleHost() || 'desktop'
// https://vite.dev/config/
export default defineConfig({
@@ -7,7 +15,7 @@ export default defineConfig({
server: {
allowedHosts: ['desktop'],
hmr: {
host: '127.0.0.1',
host: hmrHost,
protocol: 'ws',
},
fs: {