Clone, run, and explore this sample
This sample demonstrates integrating a Node.js app and an ASP.NET Core HTTP API using Aspire.
The entry point that composes every resource and dependency in this sample's distributed application.
#pragma warning disable ASPIREBROWSERLOGS001
var builder = DistributedApplication.CreateBuilder(args);
var cache = builder.AddRedis("cache") .WithRedisInsight();
var weatherapi = builder.AddProject<Projects.AspireWithNode_AspNetCoreApi>("weatherapi") .WithHttpHealthCheck("/health");
builder.AddNodeApp("frontend", "../NodeFrontend", "./app.js") .WithNpm() .WithRunScript("dev") .WithHttpEndpoint(port: 5223, env: "PORT") .WithExternalHttpEndpoints() .WithHttpHealthCheck("/health") .WithBrowserLogs() .WithReference(weatherapi).WaitFor(weatherapi) .WithReference(cache).WaitFor(cache);
builder.Build().Run();The sample consists of two apps:
- NodeFrontend: This is a simple Express-based Node.js app that renders a table of weather forecasts retrieved from a backend API and utilizes a Redis cache.
- AspireWithNode.AspNetCoreApi: This is an ASP.NET Core HTTP API that returns randomly generated weather forecast data.
Prerequisites
Section titled Prerequisites- Aspire development environment
- Node.js - at least version 22.21.1
- .NET 10 SDK
Running the app
Section titled Running the appIf using the Aspire CLI, run aspire run from this directory.
If using VS Code, open this directory as a workspace and launch the AspireWithNode.AppHost project using either the Aspire or C# debuggers.
If using Visual Studio, open the solution file AspireWithNode.slnx and launch/debug the AspireWithNode.AppHost project.
If using the .NET CLI, run dotnet run from the AspireWithNode.AppHost directory.