Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Fix webpack HMR proxying logic for apps running on non-root URLs (e.g., full IIS virtual directories) #1106

Merged
merged 1 commit into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public ConditionalProxyMiddleware(
string pathPrefix,
ConditionalProxyMiddlewareOptions options)
{
if (!pathPrefix.StartsWith("/"))
{
pathPrefix = "/" + pathPrefix;
}

_next = next;
_pathPrefix = pathPrefix;
_options = options;
Expand Down Expand Up @@ -65,7 +70,7 @@ private async Task<bool> PerformProxyRequest(HttpContext context)

requestMessage.Headers.Host = _options.Host + ":" + _options.Port;
var uriString =
$"{_options.Scheme}://{_options.Host}:{_options.Port}{context.Request.PathBase}{context.Request.Path}{context.Request.QueryString}";
$"{_options.Scheme}://{_options.Host}:{_options.Port}{context.Request.Path}{context.Request.QueryString}";
requestMessage.RequestUri = new Uri(uriString);
requestMessage.Method = new HttpMethod(context.Request.Method);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public static void UseWebpackDevMiddleware(
// plus /__webpack_hmr is proxied with infinite timeout, because it's an EventSource (long-lived request).
foreach (var publicPath in devServerInfo.PublicPaths)
{
appBuilder.UseProxyToLocalWebpackDevMiddleware(publicPath + hmrEndpoint, devServerInfo.Port, Timeout.InfiniteTimeSpan);
appBuilder.UseProxyToLocalWebpackDevMiddleware(publicPath, devServerInfo.Port, TimeSpan.FromSeconds(100));
}
appBuilder.UseProxyToLocalWebpackDevMiddleware(hmrEndpoint, devServerInfo.Port, Timeout.InfiniteTimeSpan);
}

private static void UseProxyToLocalWebpackDevMiddleware(this IApplicationBuilder appBuilder, string publicPath, int proxyToPort, TimeSpan requestTimeout)
Expand Down