minattest-app-host (BFF)
Overview
- .NET 9 minimal app acting as a reverse proxy for both the React frontend and the API during development.
- Uses YARP to forward:
/api/*to the API (API_URL, defaulthttps://localhost:7172).- everything else to the frontend dev server (
FRONTEND_URL, defaulthttp://localhost:5173).
Configure
- Env vars:
FRONTEND_URL(default:http://localhost:5173)API_URL(default:https://localhost:7172)
launchSettings.jsonsets both for dev profiles.
Run
- Start your API (e.g., at
https://localhost:7172). - Start your React dev server (e.g.,
npm run devon port 5173). - From repo root:
dotnet run --project frontend/minattest-app-host - Open the BFF URL shown in the console (e.g.,
https://localhost:10001).- Requests to
/api/...go to your API. - All other paths (including
/) go to the React dev server.
- Requests to
Notes
- WebSockets are enabled to support HMR from Vite/CRA dev servers.
- If your API uses the ASP.NET Core dev certificate, ensure it's trusted:
dotnet dev-certs https --trust. - Later, add auth and API composition here while keeping the frontend origin hidden from browsers.