Why is it necessary to raise ng in 0.0.0.0?

Asked

Viewed 378 times

-1

I installed the Angular inside a Docker container (fabiojanio/Ionic), however, I am only able to access the application when I start the server in this way:

ng serve --host 0.0.0.0

I would like to use only:

ng serve

How to do this?

  • Already tried to change the baseUrl of Protractor.conf.js?

2 answers

1


This is not necessarily in relation to the Angular, it is more related to the network and Docker.

When using the 127.0.0.1, you are telling your server to listen/serve to the virtual network adapter that serves the internal host, also known as loopback.

You need to use 0.0.0.0 so that this server, running inside your container, is accessible by all network interfaces. Including external access in the case of servers, for example.

When deploying the application to the host, you need to consider using the 0.0.0.0 for the "redirect" to enter the public network interface and the network interface of your container, to work.

If your wish is to leave the 0.0.0.0 by default, not to need to type, you will need to set in the angular settings file, something like this: https://stackoverflow.com/a/42788609/6394559

-1

Using --host 0.0.0.0 you are freeing up external access to the Angular development server.

By default the server goes up as a host localhost

What would prevent access to the angular server from outside the container.

I believe you should keep the host as you have done.

I hope I’ve helped

Browser other questions tagged

You are not signed in. Login or sign up in order to post.