diff --git a/javascript/node/selenium-webdriver/lib/webdriver.js b/javascript/node/selenium-webdriver/lib/webdriver.js
index <HASH>..<HASH> 100644
--- a/javascript/node/selenium-webdriver/lib/webdriver.js
+++ b/javascript/node/selenium-webdriver/lib/webdriver.js
@@ -1229,6 +1229,19 @@ class WebDriver {
     if (target && cdpTargets.indexOf(target.toLowerCase()) === -1) {
       throw new error.InvalidArgumentError('invalid target value')
     }
+
+    if (debuggerAddress.match(/\/se\/cdp/)) {
+      if (debuggerAddress.match("ws:\/\/", "http:\/\/")) {
+        return debuggerAddress.replace("ws:\/\/", "http:\/\/") 
+      }
+      else if (debuggerAddress.match("wss:\/\/", "https:\/\/")) {
+        return debuggerAddress.replace("wss:\/\/", "https:\/\/") 
+      }
+      else {
+      return debuggerAddress
+      }
+    }
+
     const path = '/json/version'
     let request = new http.Request('GET', path)
     let client = new http.HttpClient('http://' + debuggerAddress)
[js] Add a check for Grid CDP endpoint