How hungtrungthinh/simple-nextjs-file-server works
Project Type and Purpose
• This is a monolithic, server-rendered Next.js 13 application whose sole responsibility is to serve static files from the public directory and show a 403 “Forbidden” page for any invalid paths.
• No database or external APIs are involved. Deployment is typically on Vercel or Dokploy.
File Structure
• Top-level files: next.config.ts, tsconfig.json, ESLint/PostCSS configs, and package.json scripts.
• public/: your “file store” – any files or subfolders here are exposed over HTTP.
• src/app/: Next 13 App Router
• page.tsx, layout.tsx, globals.css – main UI and layout
• access-forbidden/page.tsx – 403 UI
• not-found.tsx – 404 UI
• src/middleware.ts: intercepts all incoming requests and enforces “only serve what’s in public, otherwise 403”.
Extract Insights from the README
• Static-only file server
• Manual file upload to public/
• 403 on invalid or dynamic routes
• Deployment: Vercel or Dokploy (auto-detect Next.js)
Main Components
a. Clients (Browsers or HTTP clients)
b. Next.js Server (Node.js runtime)
– App Router (the routing layer in src/app)
– Middleware logic (src/middleware.ts)
– React/SSR renderers for 403, 404, homepage
c. File System Storage (public/ directory)
d. Deployment Platform (Vercel / Dokploy – optional)
Relationships & Data Flows
1. Client → HTTP request to Next.js Server
2. Server.middleware inspects the path
• If file exists in public/ → static asset served directly
• Else → render and return 403 page (or 404 where appropriate)
3. Server → HTTP response back to Client
Architectural Patterns & Technologies
• File-based routing (Next.js App Router)
• Middleware for access control
• Static asset hosting
• React / SSR for error pages
• Deployment via Vercel / Dokploy