Skip to content

ionic serve --lab always tries to access localhost #3965

@t91710

Description

@t91710

Description:
I run ionic lab on a dev server on my local network. When upgrading to latest ionic-cli version it's no longer possible to connect from ionic-lab to the angular dev server since it always tries to connect to localhost instead of the address of the server. The problem is that localhost is hard coded in

const url = `${serveDetails.protocol}://localhost:${serveDetails.port}`;

It should probably look at the address of the command which ionic serve is started with, and if there is something else than 0.0.0.0 (which is also default), this address should be used when starting ionic-lab.

Steps to Reproduce:

  1. Get two computers
  2. Get the ip of the first machine, for example 192.168.1.1
  3. Run ionic serve --address 192.168.1.1 --lab --lab-host 0.0.0.0 -- --disableHostCheck
  4. From your other computer, try to access 192.168.1.1:8200 (ionic lab) -> Does not work, because it tries to connect to localhost:8100 instead of 192.168.1.1:8100

My ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (/usr/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.2.0
   @angular-devkit/build-angular : 0.13.8
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.8
   @ionic/angular-toolkit        : 1.4.1

Cordova:

   cordova (Cordova CLI) : not installed
   Cordova Platforms     : not available
   Cordova Plugins       : not available

System:

   NodeJS : v10.15.3 (/usr/bin/node)
   npm    : 6.4.1
   OS     : Linux 3.10

Other Information:
Should be easy to just use the correct variable from the ionic serve command on this row (

const url = `${serveDetails.protocol}://localhost:${serveDetails.port}`;
) instead of hardcoded localhost-string. The ionic-lab bin already supports this, I have tested to do the change locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions