electron remote url shows browser not supported

Viewed 616

I am very new to node and electron. I am following the electron simple-app example here to access a remote url https://core1-den.brightlinkip.com/webphone/

I can't seem to figure out how to make it recognize that electron is running a valid browser. It keeps giving me an error "Browser not supported". The website opens fine on Chrome.

I also tried manually setting the user-agent on electron but still shows the same error, "Browser not supported"

Here's the default useragent on electron:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Electron/8.2.1 Safari/537.36

Here's my useragent:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36

Here's my code:

const {app, BrowserWindow} = require('electron') // http://electron.atom.io/docs/api

let window = null

// Wait until the app is ready
app.once('ready', () => {
  // Create a new window
  window = new BrowserWindow({
    // Set the initial width to 800px
    width: 800,
    // Set the initial height to 600px
    height: 600,
    // Don't show the window until it ready, this prevents any white flickering
    show: false,
    webPreferences: {
      // Disable node integration in remote page
      nodeIntegration: false
    }
  })

  // URL is argument to npm start
  const url = "https://core1-den.brightlinkip.com/webphone/"
  window.loadURL(url)

  // Show window when page is ready
  window.once('ready-to-show', () => {
    window.maximize()
    window.show()
  })
})

I think this browser detection code from the remote url is relevant:

detectBrowser: function(e) {
            var t = e && e.navigator
              , n = {};
            if (n.browser = null,
            n.version = null,
            void 0 === e || !e.navigator)
                return n.browser = "Not a browser.",
                n;
            if (t.mozGetUserMedia)
                n.browser = "firefox",
                n.version = r(t.userAgent, /Firefox\/(\d+)\./, 1);
            else if (t.webkitGetUserMedia)
                n.browser = "chrome",
                n.version = r(t.userAgent, /Chrom(e|ium)\/(\d+)\./, 2);
            else if (t.mediaDevices && t.userAgent.match(/Edge\/(\d+).(\d+)$/))
                n.browser = "edge",
                n.version = r(t.userAgent, /Edge\/(\d+).(\d+)$/, 2);
            else {
                if (!e.RTCPeerConnection || !t.userAgent.match(/AppleWebKit\/(\d+)\./))
                    return n.browser = "Not a supported browser.",
                    n;
                n.browser = "safari",
                n.version = r(t.userAgent, /AppleWebKit\/(\d+)\./, 1)
            }

0 Answers
Related