Skip to content

Commit 9d6e838

Browse files
committed
Fix: allow HTTP and local URL connections to Home Assistant
CSP only allowed wss/https, and macOS ATS blocked cleartext HTTP to local domains and IPs — causing connection failures for the default HA setup (http + mDNS). Add ws/http to CSP, enable ATS local networking, and detect ATS errors in error normalization.
1 parent b7e5a90 commit 9d6e838

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

src-tauri/Info.plist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
<string/>
99
<key>CFBundleIconName</key>
1010
<string>AppIcon</string>
11+
<key>NSAppTransportSecurity</key>
12+
<dict>
13+
<key>NSAllowsLocalNetworking</key>
14+
<true/>
15+
</dict>
1116
</dict>
1217
</plist>

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"iconAsTemplate": true
2828
},
2929
"security": {
30-
"csp": "default-src 'self'; script-src 'self'; connect-src 'self' wss://* https://*; style-src 'self' 'unsafe-inline'; img-src 'self' data:;"
30+
"csp": "default-src 'self'; script-src 'self'; connect-src 'self' wss://* ws://* https://* http://*; style-src 'self' 'unsafe-inline'; img-src 'self' data:;"
3131
}
3232
},
3333
"bundle": {

src/shared/errorNormalization.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ export function normalizeConnectionError(
7373
if (str.includes("timeout") || str.includes("timed out")) {
7474
return "Connection timed out. The server may be unreachable.";
7575
}
76+
if (
77+
str.includes("cleartext") ||
78+
str.includes("app transport security") ||
79+
str.includes("ats") ||
80+
str.includes("insecure load")
81+
) {
82+
return "Cleartext HTTP blocked by macOS App Transport Security. Use https:// or a .local address.";
83+
}
7684

7785
return typeof errCode === "string" ? errCode : `Connection error: ${errCode}`;
7886
}

0 commit comments

Comments
 (0)