How to allow access outside localhost

后端 未结 15 847
失恋的感觉
失恋的感觉 2020-12-07 07:25

How can I allow access outside the localhost at Angular2? I can navigate at localhost:3030/panel easily but I can not navigate when I write my IP such as

15条回答
  •  感情败类
    2020-12-07 08:00

    You can use the following command to access with your ip.

    ng serve --host 0.0.0.0 --disable-host-check
    

    If you are using npm and want to avoid running the command every time, we can add the following line to the package.json file in the scripts section.

    "scripts": {
        ...
        "start": "ng serve --host 0.0.0.0 --disable-host-check"
        ...
    }
    

    Then you can run you app using the below command to be accessed from the other system in the same network.

    npm start
    

提交回复
热议问题