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

Commit e2030fb

Browse files
Handle publicPath=/ in HMR. Fixes #1191.
1 parent e5f1299 commit e2030fb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Microsoft.AspNetCore.SpaServices/Webpack/ConditionalProxyMiddleware.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ internal class ConditionalProxyMiddleware
2222
private readonly RequestDelegate _next;
2323
private readonly ConditionalProxyMiddlewareOptions _options;
2424
private readonly string _pathPrefix;
25+
private readonly bool _pathPrefixIsRoot;
2526

2627
public ConditionalProxyMiddleware(
2728
RequestDelegate next,
@@ -35,14 +36,15 @@ public ConditionalProxyMiddleware(
3536

3637
_next = next;
3738
_pathPrefix = pathPrefix;
39+
_pathPrefixIsRoot = string.Equals(_pathPrefix, "/", StringComparison.Ordinal);
3840
_options = options;
3941
_httpClient = new HttpClient(new HttpClientHandler());
4042
_httpClient.Timeout = _options.RequestTimeout;
4143
}
4244

4345
public async Task Invoke(HttpContext context)
4446
{
45-
if (context.Request.Path.StartsWithSegments(_pathPrefix))
47+
if (context.Request.Path.StartsWithSegments(_pathPrefix) || _pathPrefixIsRoot)
4648
{
4749
var didProxyRequest = await PerformProxyRequest(context);
4850
if (didProxyRequest)

src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ public static class WebpackDevMiddleware
1717

1818
private static readonly JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings
1919
{
20-
ContractResolver = new CamelCasePropertyNamesContractResolver(),
20+
// Note that the aspnet-webpack JS code specifically expects options to be serialized with
21+
// PascalCase property names, so it's important to be explicit about this contract resolver
22+
ContractResolver = new DefaultContractResolver(),
23+
2124
TypeNameHandling = TypeNameHandling.None
2225
};
2326

0 commit comments

Comments
 (0)