Modern Next.js 15 app using the App Router, Tailwind CSS, Redux Toolkit, and a separate API backend. The UI provides login, dashboard, admin tools, media players, and system diagnostics.
- Next.js 15 (App Router)
- React 19
- TypeScript
- Tailwind CSS 4
- Redux Toolkit + redux-persist
- Radix UI primitives, Lucide icons
- Chart.js, Framer Motion
- Node.js 18.18+ (recommended 20+)
- npm (or yarn/pnpm/bun). Examples below use npm.
- A reachable API backend that implements the endpoints used by this app (see API notes below).
Create a .env.local file in the project root:
# Base URL for the API the frontend calls
NEXT_PUBLIC_API_URL=http://localhost:5000
# Optional: cookie key used by js-cookie for storing the JWT
# If omitted, defaults to "mcToken"
NEXT_PUBLIC_TOKEN=mcToken
# Optional: change the dev server port
# PORT=3000Notes:
- The app uses browser cookies for auth. Middleware checks a cookie named
tokenfor route protection. The login flow also stores the JWT under themcTokenkey (configurable viaNEXT_PUBLIC_TOKEN). - If
NEXT_PUBLIC_API_URLis not set, the app will fall back tohttp://192.168.1.51:5000(intended for a local network setup). Set it explicitly for your environment.
npm installnpm run dev
# or override port
PORT=4000 npm run devOpen http://localhost:3000 (or your chosen port).
# Build
npm run build
# Start the production server
npm run start
# Optionally set PORT
# PORT=8080 npm run startnpm run dev— Start Next.js dev server (Turbopack)npm run build— Create production buildnpm run start— Start production servernpm run lint— Run ESLint
- The login form posts to your API:
POST /auth/loginatNEXT_PUBLIC_API_URL. - On success, the app expects
{ accessToken, refreshToken?, sessionId, user }. - The JWT is stored in two places:
- Cookie
token(used by middleware for route protection) - Cookie
mcToken(configurable viaNEXT_PUBLIC_TOKEN, used for API Authorization header)
- Cookie
- Protected routes are enforced by
middleware.tsand HOCs inlib/auth-middleware.tsx.
Configure/implement these endpoints on your backend (examples):
POST /auth/login— returns tokens and user infoGET /auth/me— returns current user infoPOST /auth/change-passwordPOST /auth/logout,POST /auth/logout-allGET /users/all,PUT /users/:id,PUT /users/admin/:id,PUT /users/admin/reset-password/:idGET /global/,POST /global/,GET /global/launchGET /audio/,GET /audio/play,GET /audio/streamGET /video/,GET /video/previews/,GET /video/stream/:name
Make sure your API enables CORS for the frontend origin and accepts Authorization: Bearer <token> headers.
-
Redirect loop to login or blank page
- Ensure the API is reachable at
NEXT_PUBLIC_API_URL. - After successful login, verify cookies: a
tokencookie must be present. AlsomcToken(or your custom token name) should exist. - Check your backend CORS settings for the dev origin (e.g.,
http://localhost:3000).
- Ensure the API is reachable at
-
CORS errors in the browser console
- Allow the frontend origin on the API and include allowed headers (e.g.,
Authorization).
- Allow the frontend origin on the API and include allowed headers (e.g.,
-
Media (audio/video) not loading
- Confirm the streaming endpoints exist and are reachable from the browser.
-
Stale or incorrect state after code/data changes
- Clear local storage and cookies (
token,mcToken) to reset persisted auth and state.
- Clear local storage and cookies (
This repo includes an educational guide for vulnerability testing. See HACKING_SETUP.md and VULNERABILITY_README.md. Use only in controlled, authorized environments.
Standard TypeScript, ESLint, and Tailwind conventions apply. Keep code clear and readable. Run npm run lint before committing.