Cordova adding port to external links on cordova run browser

born2fr4g

I'm building a test chat app client with node.js, socket.io and cordova. Executing cordova run browser browser opens to http://localhost:8000. In index.js of my cordova chat client app i got code to connect to my server side socket.io:

var socket = io.connect('https://node-socket.io-address/');
socket.on('connect', function() {.............

Problem is that i receive this kind of error:

enter image description here

So as you can see there is a port (8000) added to the link. This problem is not occuring when I run app on android device (cordova run android).

Why cordova is adding port to external links ? Can disable port adding to external links on cordova run browser ?

Koder

It's not cordova adding port to your URL, it's socket.io client, here:

  this.port = opts.port || (global.location && location.port ?
       location.port :
       (this.secure ? 443 : 80));

When port is not defined, it defaults to port of application. That is probably a bug in socket.io, since it makes sense only if webpage and server are hosted from same node. Your problem originates from the fact, that it is cordova which serves your application (on localhost:8000) and socket.io assumes that websocket will be on same port.

To avoid it, you should add port to URL or the options object.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Opening links in external device browser with Cordova/jQuery-mobile

From Dev

Cordova Wrapper App Where Internal Links Load In App, External Links Load In Browser

From Dev

External Links to load OUTSIDE of Ionic / Cordova app

From Dev

External links / InAppBrowser in Cordova / Phonegap 3.3 always behave like "_self"

From Dev

Cordova, why would InAppBrowser plugin be required to open links in system browser

From Dev

jsPDF with Cordova - Adding images

From Dev

Adding own plugin to cordova

From Dev

Cordova adding plugin fails

From Dev

Adding Cordova Platforms

From Dev

Cordova- embed a external website into cordova app

From Dev

Cordova- embed a external website into cordova app

From Dev

Adding tag to external links

From Dev

cordova-plugin-inappbrowser not opening links from APP to IOS Device default Browser

From Dev

Open an external link in Safari (cordova)

From Dev

Cordova external app + local video

From Dev

Using Cordova, how can I open external URLs in Chrome, instead of the in-app browser?

From Dev

hiding the cordova in app browser not working

From Dev

Cordova In-app Browser Limitations

From Dev

What is the browser used by cordova on iOS?

From Dev

Cordova In-app Browser Limitations

From Dev

phonertc is not defined - Cordova phonertc on browser

From Dev

Cordova not adding capabilities to appxmanifest file

From Dev

Cordova: Error adding android platform

From Dev

Adding Cordova Plugins to Platypi Project

From Dev

Error when adding cordova plugin

From Dev

How to change default browser of cordova browser platform?

From Dev

Cordova/Phonegap load external site in main Cordova webview

From Dev

How to run cordova plugins in the background?

From Dev

Cordova build | Run failed - compileDebugJavaWithJavac

Related Related

  1. 1

    Opening links in external device browser with Cordova/jQuery-mobile

  2. 2

    Cordova Wrapper App Where Internal Links Load In App, External Links Load In Browser

  3. 3

    External Links to load OUTSIDE of Ionic / Cordova app

  4. 4

    External links / InAppBrowser in Cordova / Phonegap 3.3 always behave like "_self"

  5. 5

    Cordova, why would InAppBrowser plugin be required to open links in system browser

  6. 6

    jsPDF with Cordova - Adding images

  7. 7

    Adding own plugin to cordova

  8. 8

    Cordova adding plugin fails

  9. 9

    Adding Cordova Platforms

  10. 10

    Cordova- embed a external website into cordova app

  11. 11

    Cordova- embed a external website into cordova app

  12. 12

    Adding tag to external links

  13. 13

    cordova-plugin-inappbrowser not opening links from APP to IOS Device default Browser

  14. 14

    Open an external link in Safari (cordova)

  15. 15

    Cordova external app + local video

  16. 16

    Using Cordova, how can I open external URLs in Chrome, instead of the in-app browser?

  17. 17

    hiding the cordova in app browser not working

  18. 18

    Cordova In-app Browser Limitations

  19. 19

    What is the browser used by cordova on iOS?

  20. 20

    Cordova In-app Browser Limitations

  21. 21

    phonertc is not defined - Cordova phonertc on browser

  22. 22

    Cordova not adding capabilities to appxmanifest file

  23. 23

    Cordova: Error adding android platform

  24. 24

    Adding Cordova Plugins to Platypi Project

  25. 25

    Error when adding cordova plugin

  26. 26

    How to change default browser of cordova browser platform?

  27. 27

    Cordova/Phonegap load external site in main Cordova webview

  28. 28

    How to run cordova plugins in the background?

  29. 29

    Cordova build | Run failed - compileDebugJavaWithJavac

HotTag

Archive