Skip to content

Commit 99daf63

Browse files
committed
fix(rest): Listen on all interfaces if host is not configured
1 parent aa9812f commit 99daf63

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/rest/src/rest-server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ export class RestServer extends Context implements Server {
138138
options.port = 3000;
139139
}
140140
if (options.host == null) {
141-
options.host = 'localhost';
141+
// Set it to '' so that the http server will listen on all interfaces
142+
options.host = undefined;
142143
}
143144
this.bind(RestBindings.PORT).to(options.port);
144145
this.bind(RestBindings.HOST).to(options.host);

packages/rest/test/unit/rest-server/rest-server.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ describe('RestServer', () => {
7171
expect(server.getSync(RestBindings.PORT)).to.equal(3000);
7272
});
7373

74-
it('uses http host localhost by default', async () => {
74+
it('uses undefined http host by default', async () => {
7575
const app = new Application({
7676
components: [RestComponent],
7777
});
7878
const server = await app.getServer(RestServer);
7979
const host = await server.getSync(RestBindings.HOST);
80-
expect(host).to.equal('localhost');
80+
expect(host).to.be.undefined();
8181
});
8282

8383
it('can set port 0', async () => {

0 commit comments

Comments
 (0)