A JWT authentication demo app available in three fully supported implementations:
| Implementation | Backend | Frontend | Database | Folder |
|---|---|---|---|---|
| .NET + Angular | ASP.NET Core 8 Web API | Angular (standalone + signals) | SQL Server | JwtAuth/ + Front-end/ |
| Node.js | Express.js | Next.js | MongoDB | Node/ |
| Python | FastAPI | Next.js | PostgreSQL | Python/ |
Historical live demos from the original project docs:
- Account registration, sign-in, refresh-token based auth, and sign-out
- Profile update including avatar upload
- Password change and admin password reset
- Claim/role based admin actions (manage users)
- Session lock after inactivity and unlock with password
- Node.js (LTS recommended), Express.js, Next.js, MongoDB + Mongoose
- JWT access tokens + HTTP-only refresh-token cookies
Node/
backend/ # Express API
frontend/ # Next.js app
cd Node/backend
cp .env.example .env # fill in MONGODB_URI, JWT_SECRET, etc.
npm install
npm run devAPI runs at http://localhost:4000 by default.
Key env vars in Node/backend/.env:
| Variable | Description |
|---|---|
MONGODB_URI |
MongoDB connection string |
JWT_SECRET |
Signing secret for JWTs |
JWT_ISSUER |
JWT issuer claim |
JWT_AUDIENCE |
JWT audience claim |
FRONTEND_ORIGIN |
CORS allowed origin |
ADMIN_EMAIL |
Seeded admin email |
ADMIN_PASSWORD |
Seeded admin password |
cd Node/frontend
cp .env.local.example .env.local # set NEXT_PUBLIC_API_ROOT
npm install
npm run devApp runs at http://localhost:3000 by default.
# Backend
cd Node/backend && npm start
# Frontend
cd Node/frontend && npm run build && npm start- Python 3.11+, FastAPI, SQLAlchemy, PostgreSQL
- Next.js 14 frontend
- JWT access tokens + HTTP-only refresh-token cookies
Python/
backend/ # FastAPI API
frontend/ # Next.js app
cd Python/backend
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
copy .env.example .env
uvicorn app.main:app --reload --port 8000API runs at http://localhost:8000 by default.
Key env vars in Python/backend/.env:
| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string |
JWT_SECRET |
Signing secret for JWTs |
JWT_ISSUER |
JWT issuer claim |
JWT_AUDIENCE |
JWT audience claim |
FRONTEND_ORIGIN |
CORS allowed origin |
ADMIN_EMAIL |
Seeded admin email |
ADMIN_PASSWORD |
Seeded admin password |
cd Python/frontend
copy .env.local.example .env.local # set NEXT_PUBLIC_API_ROOT
npm install
npm run devApp runs at http://localhost:3000 by default.
# Backend
cd Python/backend && uvicorn app.main:app --host 0.0.0.0 --port 8000
# Frontend
cd Python/frontend && npm run build && npm start- C#, ASP.NET Core 8 Web API, Entity Framework Core, SQL Server
- Angular 18+, standalone components, signal queries, Angular Material, Bootstrap 5
JwtAuth/ # ASP.NET Web API backend
Front-end/ # Angular frontend
- Copy
JwtAuth/appsettings.Demo.jsontoJwtAuth/appsettings.jsonand fill in the database connection string, JWT secret, admin seed data, and CORS origins. - Run EF Core migrations from the Package Manager Console:
Add-Migration initial Update-Database - Build and run via Visual Studio or the .NET CLI.
cd Front-end
npm installSet API_ROOT in src/environments/environment.ts (and environment.prod.ts) to your backend URL, then run:
ng serveFor HTTPS with a self-signed certificate:
ng serve --ssl true --ssl-key path/to/privateKey.key --ssl-cert path/to/certificate.crtOpenSSL example from the original setup notes:
req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crtIf API and frontend are hosted on different domains during testing, enable withCredentials in Angular HTTP interceptors so refresh-token cookies are sent cross-site.
- Publish the Web API project (Folder publish) and copy the output to your site root.
- Build the Angular app:
For Node.js v17+ environments that require legacy OpenSSL provider:
ng build -c production --output-path dist/wwwroot --base-href /
set NODE_OPTIONS=--openssl-legacy-provider ng build -c production --output-path dist/wwwroot --base-href / - Copy
dist/wwwrootto your site root alongside the API. - Add URL rewrite rules to
web.configso Angular routes fall through toindex.htmlwhile/api/*and static files are served directly. SeeJwtAuth/example_for_shared_iis_hosting_web.configfor a full example. - If HTTP DELETE calls fail on IIS, remove WebDAV module/handler entries in
web.configas in the original deployment notes.
- The Node.js, Python, and .NET stacks are independent — you can run any one without the others.
- For Node.js, if the backend exits with a MongoDB connection error, ensure MongoDB is running locally or update
MONGODB_URIto a remote instance. - For Python, if startup fails, verify PostgreSQL is reachable from
DATABASE_URL.