Amit Dube
Amit Dube

Reputation: 1027

How to start HTTP Server on all network interfaces in LoopBack 4

I have created a new application using LoopBack 4 cli. I want to start the application on all interfaces 0.0.0.0 instead of 127.0.0.1.

How can I do that?

Also how to change port number of application starting?

Upvotes: 1

Views: 526

Answers (1)

Aritra Chakraborty
Aritra Chakraborty

Reputation: 12542

For LB4:

If you are using RestApplication, according to this and this

You can pass the host here:

const app = new RestApplication({
  rest: {
    port: 3001,
    host: "my-host"
  },
});

Or if you are using your own application which extends any Application you can just pass it to super:

export class MyApplication extends RestApplication {
  constructor() {
    super({
      rest: {
        port: 4000,
        host: 'my-host',
      },
    });
  }
}

If you are using LB3:
There is config file in /server folder called config.json. There change the host to:

{
  "restApiRoot": "/v1",
  "host": "0.0.0.0",
  "port": 5000,
  .
  .
  .
  "legacyExplorer": false
}

Upvotes: 4

Related Questions