This example demonstrates how to intercept, protect, rewrite, and redirect HTTP requests using Ranu.js Middleware.
- Path Matching:
config = { matcher: ['/*'] }matches incoming request routes - Authentication Guard: Intercepting requests targeting
/protectedand redirecting unauthorized visitors to/login - Internal Rewrites: Silently rewriting paths without altering the user-facing URL in the browser bar
├── app/
│ ├── layout.tsx
│ ├── login/page.tsx
│ ├── page.tsx
│ └── protected/page.tsx
├── middleware.ts # Top-level request middleware
├── package.json
├── ranu.config.ts
└── tsconfig.json
pnpm dev