Skip to content

Commit 75c57e7

Browse files
committed
switch to new RunNodeProcess + connecting html page
1 parent ca7d9b9 commit 75c57e7

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

MyApp/Program.cs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Net;
2+
using System.Net.Sockets;
23
using Microsoft.AspNetCore.DataProtection;
34
using Microsoft.AspNetCore.Identity;
45
using MyApp.Data;
@@ -69,35 +70,16 @@
6970
options.MapEndpoints();
7071
});
7172

72-
// Proxy development HMR WebSocket and fallback routes to the Next server
7373
if (app.Environment.IsDevelopment())
7474
{
75-
// Start the Angular dev server if it's not running
76-
bool IsPortAvailable(int port) => System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()
77-
.GetActiveTcpListeners().All(x => x.Port != port);
78-
if (IsPortAvailable(4200) && nodeProxy.TryStartNode("../MyApp.Client", out var process))
79-
{
80-
app.Lifetime.ApplicationStopping.Register(() => {
81-
if (!process.HasExited)
82-
{
83-
nodeProxy.Log.LogDebug("Terminating process: " + process.Id);
84-
process.Kill(entireProcessTree: true);
85-
}
86-
});
87-
}
88-
75+
app.RunNodeProcess(nodeProxy, "../MyApp.Client"); // Start Node if not running
8976
app.UseWebSockets();
90-
app.MapViteHmr(nodeProxy);
91-
app.MapFallbackToNode(nodeProxy);
92-
93-
// Wait for Angular Dev Server to start...
94-
ExecUtils.RetryOnException(() =>
95-
nodeProxy.Client.GetStringAsync("/").Wait(), timeOut:TimeSpan.FromSeconds(30));
77+
app.MapViteHmr(nodeProxy); // Proxy HMR WebSocket requests
78+
app.MapFallbackToNode(nodeProxy); // Fallback to Node dev server in development
9679
}
9780
else
98-
{
99-
// Map fallback to index.html in production (MyApp.Client/dist > wwwroot)
100-
app.MapFallbackToFile("index.html");
81+
{
82+
app.MapFallbackToFile("index.html"); // Fallback to index.html in production (MyApp.Client/dist > wwwroot)
10183
}
10284

103-
app.Run();
85+
app.Run();

NuGet.Config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="ServiceStack MyGet feed" value="https://www.myget.org/F/servicestack" />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
6+
</packageSources>
7+
</configuration>

0 commit comments

Comments
 (0)