Allow unsafe ports on ionic request


Hello, I am having an issue with both Android and iOS,
I am trying to execute a request to a url with port 6000, but the request is throwing the following error:

failed to load resource: net:: ERR_UNSAFE_PORT

According to my research port 6000 is indeed an unsafe port on most browsers, however, changing that port on the server side is not an option. I have also done some research and found that launching the browser using the following parameter (at least for Chome): --explicitly-allowed-ports=6000 will add an exception, allowing the request to be done over the required port. So my question is, how can I include this extra parameter to Ionic webviews so It can use it when calling the browser. Or there is another work around to allow ionic webviews to execute unsafe ports? Thanks a lot.


I fear this won’t work, I have never seen anything like this before.

But I can suggest a workaround: Write a small script on your server that takes all requests and forwards them to you domain:6000. 3 lines of PHP should be enough and then you can use a normal port 80 URL in your app.


Probably easier and safer to just use the webserver configuration. For example, adapted from what I typically use for nginx:

    location /api {
      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;
      proxy_pass          http://localhost:6000;
      proxy_read_timeout  90;