Skip to content

Commit 6016c99

Browse files
feat: allow connecting to http localhost nodes (#7799)
* feat: allow http localhost * fix: allow if !developerProfile * fix: condition * fix: add lowercase method * fix: allow localhost nodes using http --------- Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
1 parent c3f2c47 commit 6016c99

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/shared/lib/core/network/utils/checkNodeUrlValidity.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@ export function checkNodeUrlValidity(
1515
newUrl: string,
1616
allowInsecure: boolean
1717
): string | undefined {
18+
const isHttpLocalhost =
19+
newUrl.toLowerCase().startsWith('http://localhost') || newUrl.toLowerCase().startsWith('http://127.0.0.1')
20+
1821
if (!isValidUrl(newUrl)) {
1922
return 'error.node.invalid'
2023
}
21-
22-
if (!allowInsecure && !isValidHttpsUrl(newUrl)) {
24+
if (!allowInsecure && !isHttpLocalhost && !isValidHttpsUrl(newUrl)) {
2325
return 'error.node.https'
2426
}
2527

2628
const hasDefaultHttpsPort = newUrl.endsWith(':443')
27-
if (hasDefaultHttpsPort) {
29+
if (hasDefaultHttpsPort && !isHttpLocalhost) {
2830
newUrl = newUrl.slice(0, -4)
2931
}
3032

packages/shared/locales/en.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@
19791979
"refused": "The connection was refused.",
19801980
"handshake": "Could not complete handshake with node.",
19811981
"invalidCertificate": "Could not connect with invalid certificate.",
1982-
"https": "HTTPS is required; insecure connections over HTTP are not supported at this time.",
1982+
"https": "External connections must use HTTPS; localhost connections can be made using HTTP. Insecure external HTTP connections are not supported.",
19831983
"duplicate": "This node has already been added.",
19841984
"noSyncedNode": "No synced node is available.",
19851985
"timeNotSynced": "Device time is incorrect, unable to sync node.",

0 commit comments

Comments
 (0)