fix(tauri-app): vite bind 127.0.0.1 (not localhost)
vite's `host: host || false` config falls back to vite's
`server.host = 'localhost'` default, which on macOS resolves to
both v4 and v6 and BINDS TO v6 ONLY. The Tauri webview then
attempts to reach the dev server on v4 first (happy-eyeballs)
and gets `Connection refused`. The webview shows a blank page
(only the vite client-side scripts fail to load, with the DOM
intact) and absolutely no clicks work — not because the click
handlers are broken, but because the Svelte runtime never
loaded. The user reported 'search tut sich nix genau auch bei
compose etc.' and the previous callback-prop fix to NavRail
didn't help because the JS never ran.
Two coordinated fixes:
1. `vite.config.ts`: `host: host || '127.0.0.1'` — explicit
IPv4-only binding that matches the `devUrl` in
tauri.conf.json (`http://127.0.0.1:1430`).
2. `tauri.conf.json`: `devUrl: 'http://127.0.0.1:1430'`
instead of `http://localhost:1430` — unambiguous.
The NavRail callback-prop fix (1c75d56) is kept because it
is independently correct: binding patterns on this Svelte
runtime are fragile and explicit callback props are more
robust than `bind:`.
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"identifier": "de.eifelcloud.maarcadetweet",
|
"identifier": "de.eifelcloud.maarcadetweet",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
"devUrl": "http://localhost:1430",
|
"devUrl": "http://127.0.0.1:1430",
|
||||||
"beforeBuildCommand": "npm run build",
|
"beforeBuildCommand": "npm run build",
|
||||||
"frontendDist": "../dist"
|
"frontendDist": "../dist"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,7 +17,16 @@ export default defineConfig(async () => ({
|
|||||||
server: {
|
server: {
|
||||||
port: 1430,
|
port: 1430,
|
||||||
strictPort: true,
|
strictPort: true,
|
||||||
host: host || false,
|
// Always bind to IPv4 127.0.0.1 explicitly. `host || false` lets
|
||||||
|
// vite pick "localhost" which on macOS resolves to both v4 and v6
|
||||||
|
// and binds to v6 by default — the Tauri webview then tries v4
|
||||||
|
// first and gets a connection refused. The explicit v4 address
|
||||||
|
// matches `tauri.conf.json`'s `devUrl` so the webview connects
|
||||||
|
// reliably. HMR via Tauri (cross-platform) still works because
|
||||||
|
// vite binds both v4 and v6 in modern versions when the address
|
||||||
|
// is the v4 loopback; if that breaks for someone we can use
|
||||||
|
// `0.0.0.0` to listen on all interfaces instead.
|
||||||
|
host: host || "127.0.0.1",
|
||||||
hmr: host
|
hmr: host
|
||||||
? { protocol: "ws", host, port: 1431 }
|
? { protocol: "ws", host, port: 1431 }
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user