auth_routing

Enforce JWT authentication and route boundaries in Next.js via src/proxy.ts.

21|4|Updated Feb 20, 2026
One-click install
npx skills add https://github.com/arunoda/OkBrain --skill auth-routing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth_routing
Source: https://github.com/arunoda/OkBrain/tree/main/.agent/skills/auth_routing
Command: npx skills add https://github.com/arunoda/OkBrain --skill auth-routing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the need for robust authentication and request routing in Next.js applications, ensuring that only authorized users can access protected resources.

Core Features & Use Cases

  • Authentication Enforcement: Verifies user sessions via JWT cookies before allowing access to application routes.
  • Public Path Management: Allows specific routes (e.g., login, public API endpoints) to be accessed without authentication.
  • Request Handling: Intercepts requests to modify headers, perform redirects, or return specific error responses (like 401 for unauthorized API access).
  • Use Case: Protect your entire application except for the /login page and /api/auth/login endpoint, redirecting any unauthenticated user attempting to access other routes to the login page.

Quick Start

Add the '/new-public-route/' path to the publicPaths array in src/proxy.ts to make it accessible without authentication.

Frequently Asked Questions about auth_routing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce JWT authentication for Next.js API routes and application pages?

JWT authentication in Next.js is enforced by intercepting requests through a proxy middleware that verifies user sessions via JWT cookies before allowing access to protected application routes and API endpoints. Unauthenticated API calls receive a 401 response.

How do I make specific Next.js routes public while protecting the rest of the application?

To make specific Next.js routes public, add the desired path, such as `/new-public-route/`, to the `publicPaths` array in `src/proxy.ts`. This excludes specified routes from JWT authentication checks while keeping other application paths protected.

What happens when an unauthenticated user tries to access a protected Next.js route?

When unauthenticated users access protected Next.js routes, the proxy routing mechanism handles unauthorized access by returning a 401 status for API calls or redirecting browser navigation to the `/login` page for other application routes.

Can I use proxy routing to manage authentication boundaries without additional middleware dependencies?

Yes, proxy routing manages authentication and routing boundaries directly within Next.js applications using `src/proxy.ts`. It intercepts requests to modify headers, perform redirects, or return specific error responses without requiring external middleware dependencies.

Does Next.js proxy routing support custom login endpoints alongside public path management?

Next.js proxy routing supports custom login endpoints by excluding specific public paths like `/login` and `/api/auth/login` from authentication enforcement. This allows users to access login functionality while securing the rest of the application.

Why should I use proxy routing instead of standard Next.js middleware for authentication?

Proxy routing provides a centralized authentication boundary in `src/proxy.ts` that explicitly handles JWT cookie verification, public path exclusion, and differentiated responses for API versus application routes, ensuring robust access control for protected resources.