Skip to content

Commit

Permalink
feat: allow connecting to http localhost nodes (#7799)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
evavirseda and begonaalvarezd authored Jan 25, 2024
1 parent c3f2c47 commit 6016c99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit 6016c99

Please sign in to comment.