Next.js Proxy

Installation
SKILL.md

Next.js Proxy

Expert guidance on using Next.js Proxy (formerly Middleware) to run code before requests complete — redirects, rewrites, header modification, and route matching.

@doc-version: 16.2.6

Core Concepts

Proxy (เดิมคือ Middleware — เปลี่ยนชื่อตั้งแต่ Next.js 16) ให้คุณรัน code ก่อน request จะเสร็จสมบูรณ์ สามารถ:

  • Redirect ไปหน้าอื่น
  • Rewrite URL
  • แก้ไข request/response headers
  • ตอบกลับโดยตรง (ไม่ผ่าน route)

Guidelines

1. Convention

สร้างไฟล์ proxy.ts ที่ project root (หรือใน src/ ถ้าใช้):

Installs
–
First Seen
–
Next.js Proxy — yuen30/my-skills