@@ -48,27 +48,19 @@ public static void Attach(
48
48
var diagnosticSource = appBuilder . ApplicationServices . GetRequiredService < DiagnosticSource > ( ) ;
49
49
var angularCliServerInfoTask = StartAngularCliServerAsync ( sourcePath , scriptName , pkgManagerCommand , devServerPort , logger , diagnosticSource , applicationStoppingToken ) ;
50
50
51
- // Everything we proxy is hardcoded to target http://localhost because:
52
- // - the requests are always from the local machine (we're not accepting remote
53
- // requests that go directly to the Angular CLI middleware server)
54
- // - given that, there's no reason to use https, and we couldn't even if we
55
- // wanted to, because in general the Angular CLI server has no certificate
56
- var targetUriTask = angularCliServerInfoTask . ContinueWith (
57
- task => new UriBuilder ( "http" , "localhost" , task . Result . Port ) . Uri ) ;
58
-
59
51
SpaProxyingExtensions . UseProxyToSpaDevelopmentServer ( spaBuilder , ( ) =>
60
52
{
61
53
// On each request, we create a separate startup task with its own timeout. That way, even if
62
54
// the first request times out, subsequent requests could still work.
63
55
var timeout = spaBuilder . Options . StartupTimeout ;
64
- return targetUriTask . WithTimeout ( timeout ,
56
+ return angularCliServerInfoTask . WithTimeout ( timeout ,
65
57
$ "The Angular CLI process did not start listening for requests " +
66
58
$ "within the timeout period of { timeout . TotalSeconds } seconds. " +
67
59
$ "Check the log output for error information.") ;
68
60
} ) ;
69
61
}
70
62
71
- private static async Task < AngularCliServerInfo > StartAngularCliServerAsync (
63
+ private static async Task < Uri > StartAngularCliServerAsync (
72
64
string sourcePath , string scriptName , string pkgManagerCommand , int portNumber , ILogger logger , DiagnosticSource diagnosticSource , CancellationToken applicationStoppingToken )
73
65
{
74
66
if ( portNumber == default ( int ) )
@@ -99,13 +91,12 @@ private static async Task<AngularCliServerInfo> StartAngularCliServerAsync(
99
91
}
100
92
101
93
var uri = new Uri ( openBrowserLine . Groups [ 1 ] . Value ) ;
102
- var serverInfo = new AngularCliServerInfo { Port = uri . Port } ;
103
94
104
95
// Even after the Angular CLI claims to be listening for requests, there's a short
105
96
// period where it will give an error if you make a request too quickly
106
97
await WaitForAngularCliServerToAcceptRequests ( uri ) ;
107
98
108
- return serverInfo ;
99
+ return uri ;
109
100
}
110
101
111
102
private static async Task WaitForAngularCliServerToAcceptRequests ( Uri cliServerUri )
@@ -146,10 +137,5 @@ await client.SendAsync(
146
137
}
147
138
}
148
139
}
149
-
150
- class AngularCliServerInfo
151
- {
152
- public int Port { get ; set ; }
153
- }
154
140
}
155
141
}
0 commit comments