public WebpackProxyRequestHandler( string pathPrefix, WebpackProxyRequestHandlerOptions options) { if (!pathPrefix.StartsWith("/")) { pathPrefix = "/" + pathPrefix; } this._pathPrefix = pathPrefix; this._pathPrefixIsRoot = string.Equals(this._pathPrefix, "/", StringComparison.Ordinal); this._options = options; this._httpClient = new HttpClient(new HttpClientHandler()); this._httpClient.Timeout = this._options.RequestTimeout; }
private void RegisterProxyToLocalWebpackDevMiddleware(string publicPath, int proxyToPort, TimeSpan requestTimeout) { // Note that this is hardcoded to make requests to "localhost" regardless of the hostname of the // server as far as the client is concerned. This is because ConditionalProxyMiddlewareOptions is // the one making the internal HTTP requests, and it's going to be to some port on this machine // because aspnet-webpack hosts the dev server there. We can't use the hostname that the client // sees, because that could be anything (e.g., some upstream load balancer) and we might not be // able to make outbound requests to it from here. // Also note that the webpack HMR service always uses HTTP, even if your app server uses HTTPS, // because the HMR service has no need for HTTPS (the client doesn't see it directly - all traffic // to it is proxied), and the HMR service couldn't use HTTPS anyway (in general it wouldn't have // the necessary certificate). var proxyOptions = new WebpackProxyRequestHandlerOptions( "http", "localhost", proxyToPort.ToString(), requestTimeout); this._proxyHandlers.Add(new WebpackProxyRequestHandler(publicPath, proxyOptions)); }