Skip to content

About

CLI that turns a local Angular + ASP.NET Core project into one temporary, single-origin demo link via an embedded YARP reverse proxy.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

LocalDeploy

LocalDeploy turns a local Angular + ASP.NET Core project into one temporary, shareable demo link — one command, one origin, no manual proxy wiring.

Tunneling a local port is already a solved problem (Cloudflare Tunnel, ngrok, Microsoft Dev Tunnels — the last one ships inside launchSettings.json). LocalDeploy doesn't compete there. What it actually does:

  1. Merges frontend + backend into one origin. Dev Tunnels gives you a separate public URL per port, which means your Angular app's calls to the API become cross-origin the moment you tunnel. LocalDeploy runs a YARP reverse proxy in front of both, so the browser only ever talks to one origin — zero CORS configuration, ever.
  2. Never touches your source. The Angular dev server is wired to the API through a proxy config file LocalDeploy generates and passes via ng serve --proxy-config — environment.ts and every other committed file stay untouched.

This repo currently implements Milestone 0: the proof of concept that the routing and WebSocket pass-through actually work end-to-end before anything else (tunneling, auth, expiry) gets built on top.

Architecture

                     ┌─────────────────────────────────────────┐
                     │        LocalDeploy.Cli (.NET 8)          │
                     │                                           │
   dotnet run  ───▶  │  1. spawns  dotnet run  (ASP.NET Core API)│
                     │  2. writes  proxy.conf.json (temp file)   │
                     │  3. spawns  ng serve --proxy-config ...   │
                     │  4. hosts YARP on ONE local port          │
                     └─────────────────────────────────────────┘
                                        │
                       http://localhost:5500  (single origin)
                                        │
                 ┌──────────────────────┴──────────────────────┐
                 │                                              │
            /app/**                                         /api/**
                 │                                              │
                 ▼                                              ▼
     Angular dev server (ng serve)                 ASP.NET Core API (Kestrel)
        :4300, --serve-path /app/                       :5100
                                                     + SignalR hub (/api/hub)
  • Reverse proxy: YARP, embedded in the same .NET process as the CLI — routes are built in code (LoadFromMemory), not appsettings.json, since the Angular dev-server port is only known after the CLI spawns it.
  • Angular ↔ API wiring: a temporary proxy.conf.json is generated per run and passed to ng serve --proxy-config. ng serve also runs with --serve-path /app/ so its own dev-server internals (Vite's /@vite/client, /@fs/... module paths) are correctly prefixed to match the /app route YARP forwards — otherwise those absolute dev-only asset paths 404 the moment the app is served under a subpath.
  • WebSockets / SignalR: YARP forwards WebSocket upgrades by default — no extra configuration needed. Verified with a live SignalR hub round trip through the full chain (browser → YARP → Kestrel).
  • Known limitation (by design, for now): this only works cleanly if the Angular app calls relative URLs (/api/...). Apps with hardcoded absolute http://localhost:5000 calls are out of scope for Milestone 0.

What's in this repo

Path What it is
src/LocalDeploy.Cli The orchestrator: spawns the API + Angular dev server, generates the proxy config, hosts the YARP proxy on one port, and tears everything down cleanly on exit.
src/LocalDeploy.Api A minimal ASP.NET Core API — one REST endpoint (GET /api/hello) and one SignalR hub (/api/hub) — standing in for "your real backend."
src/demo-app A bare Angular app that calls the API via relative /api/... paths only, and connects to the SignalR hub. Standing in for "your real frontend."

Running it

Prerequisites: .NET 8 SDK, Node.js, Angular CLI (npm i -g @angular/cli).

git clone <this-repo>
cd LocalDeploy
cd src/demo-app && npm install && cd ../..
dotnet run --project src/LocalDeploy.Cli

Once both child processes are up, open http://localhost:5500/app/. The page will:

  • Call GET /api/hello and render the response — proxied straight through YARP, same origin, no CORS headers required.
  • Open a SignalR connection to /api/hub and show connected — confirming the WebSocket upgrade survives the proxy hop.
  • Let you click Send Ping to round-trip a message through the hub live.

Ctrl+C stops the CLI and kills both spawned child processes (and their subprocess trees) — nothing is left running, nothing was permanently modified.

Milestone 0 acceptance criteria

  • A real Angular app and a real ASP.NET Core API run locally.
  • YARP routes /app → Angular dev server, /api → ASP.NET Core API, from one local port.
  • ng serve --proxy-config is generated and launched automatically — no source edits.
  • From the single local URL: the Angular app loads and calls the API with zero CORS errors.
  • A SignalR call works end-to-end through the tunnel-ready proxy chain.
  • Cloudflare quick tunnel exposure — deferred to the next milestone by design (see below).

Roadmap

Milestone 1 (next), in order:

  1. localdeploy inspect — detect Angular/.NET ports from angular.json / launchSettings.json, with a localdeploy.yml override as fallback.
  2. Cloudflare quick tunnel (cloudflared tunnel --url http://localhost:<proxyPort>) exposing the single YARP port publicly, with non-Development error handling forced on the API the moment a tunnel is active (no stack traces leaking to a public link).
  3. Password protection (--password).
  4. Expiration (--duration).
  5. A minimal landing page (link + password prompt + expiry) for non-technical recipients.

Explicitly out of scope for now: a custom relay server, a project dashboard, demo reset, multi-framework detection (React/Node/Docker), OAuth, billing.

About

CLI that turns a local Angular + ASP.NET Core project into one temporary, single-origin demo link via an embedded YARP reverse proxy.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages