feat(cli,run): resolve app url based on available network interfaces

This commit is contained in:
2023-04-06 11:52:04 +02:00
parent 050e529f0a
commit 32c6f0a77e
3 changed files with 80 additions and 7 deletions

View File

@ -26,11 +26,21 @@ describe('App Module', function() {
})
});
it('should retrieve requested app url', function() {
it('should retrieve requested app url without from address', function() {
return Edge.rpc("getAppUrl", { appId: "edge.sdk.client.test" })
.then(url => {
console.log("getAppUrl result:", url);
chai.assert.isNotEmpty(url);
chai.assert.match(url, /^http:\/\/0\.0\.0\.0/)
})
});
it('should retrieve requested app url with from address', function() {
return Edge.rpc("getAppUrl", { appId: "edge.sdk.client.test", from: "127.0.0.2" })
.then(url => {
console.log("getAppUrl result:", url);
chai.assert.isNotEmpty(url);
chai.assert.match(url, /^http:\/\/127\.0\.0\.1/)
})
});

View File

@ -96,7 +96,9 @@ function getApp(ctx, params) {
function getAppUrl(ctx, params) {
var appId = params.appId;
return app.getUrl(ctx, appId);
var from = params.from;
return app.getUrl(ctx, appId, from ? from : '');
}
function onClientFetch(ctx, url, remoteAddr) {