Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow connecting to http localhost nodes #7799

Merged
merged 8 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ export function checkNodeUrlValidity(
newUrl: string,
allowInsecure: boolean
): string | undefined {
const isHttpLocalhost =
newUrl.toLowerCase().startsWith('http://localhost') || newUrl.toLowerCase().startsWith('http://127.0.0.1')

if (!isValidUrl(newUrl)) {
return 'error.node.invalid'
}

if (!allowInsecure && !isValidHttpsUrl(newUrl)) {
if (!allowInsecure && !isHttpLocalhost && !isValidHttpsUrl(newUrl)) {
return 'error.node.https'
}

const hasDefaultHttpsPort = newUrl.endsWith(':443')
if (hasDefaultHttpsPort) {
if (hasDefaultHttpsPort && !isHttpLocalhost) {
newUrl = newUrl.slice(0, -4)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@
"refused": "The connection was refused.",
"handshake": "Could not complete handshake with node.",
"invalidCertificate": "Could not connect with invalid certificate.",
"https": "HTTPS is required; insecure connections over HTTP are not supported at this time.",
"https": "External connections must use HTTPS; localhost connections can be made using HTTP. Insecure external HTTP connections are not supported.",
"duplicate": "This node has already been added.",
"noSyncedNode": "No synced node is available.",
"timeNotSynced": "Device time is incorrect, unable to sync node.",
Expand Down