66using Microsoft . VisualStudio . Threading ;
77using System . CommandLine ;
88using System . CommandLine . Invocation ;
9+ using System . Net ;
910
1011namespace DevProxy . CommandHandlers ;
1112
@@ -25,7 +26,7 @@ public int Invoke(InvocationContext context)
2526 {
2627 var joinableTaskContext = new JoinableTaskContext ( ) ;
2728 var joinableTaskFactory = new JoinableTaskFactory ( joinableTaskContext ) ;
28-
29+
2930 return joinableTaskFactory . Run ( async ( ) => await InvokeAsync ( context ) ) ;
3031 }
3132
@@ -40,7 +41,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
4041 var builder = WebApplication . CreateBuilder ( ) ;
4142 builder . Logging . AddFilter ( "Microsoft.Hosting.*" , LogLevel . Error ) ;
4243 builder . Logging . AddFilter ( "Microsoft.AspNetCore.*" , LogLevel . Error ) ;
43-
44+
4445 // API controller is registered first and so is the last service to be disposed of when the app is shutdown
4546 builder . Services . AddControllers ( ) ;
4647
@@ -59,10 +60,12 @@ public async Task<int> InvokeAsync(InvocationContext context)
5960 options . LowercaseUrls = true ;
6061 } ) ;
6162
63+ var ipAddress = context . ParseResult . GetValueForOption < string ? > ( ProxyHost . IpAddressOptionName , _options ) ;
64+ ipAddress ??= "127.0.0.1" ;
6265 builder . WebHost . ConfigureKestrel ( options =>
6366 {
64- options . ListenLocalhost ( ConfigurationFactory . Value . ApiPort ) ;
65- _logger . LogInformation ( "Dev Proxy API listening on http://localhost :{Port}..." , ConfigurationFactory . Value . ApiPort ) ;
67+ options . Listen ( IPAddress . Parse ( ipAddress ) , ConfigurationFactory . Value . ApiPort ) ;
68+ _logger . LogInformation ( "Dev Proxy API listening on http://{IPAddress} :{Port}..." , ipAddress , ConfigurationFactory . Value . ApiPort ) ;
6669 } ) ;
6770
6871 var app = builder . Build ( ) ;
0 commit comments