Next.jsのMiddleware
Enabling full flexibility in Next.js with code over configuration
めちゃくちゃ雑に言うと、reqが飛んできてから、resを返すまでの間にやる処理のことかmrsekut.icon
Vercel Functionsを使用する
reqが来てから、resの選択ができるので、固定のものを返すCDNとは違って、ユーザー特有の情報を返せる
docs
#WIP
これどこに置くの?
repo/app/middleware.tsで良いの?
違いそうmrsekut.icon
repo/middleware.tsみたいだ
console.logを仕込んで何度かdeployしてVercelのLogのところで確認した方が良い
https://github.com/vercel/next.js/discussions/29750
https://twitter.com/vercel/status/1453033490551742464
Vercel Functions
https://nextjs.org/docs/middleware
https://zenn.dev/catnose99/articles/0df722f3f025bb
https://speakerdeck.com/takefumiyoshii/nextjs-make-the-web-faster
Next.jsのEdge Runtime
https://nextjs.org/docs/api-reference/edge-runtime