[TIL] Protecting your routes with Middleware
Dec 15, 2023 | Jun 25, 2024
| Ryoon.With.Wisdomtrees
Middleware관련된 정보는 이 페이지에 업데이트하자.(23.12.15기준)
The
authorized
callback is used to verify if the request is authorized to access a page via Next.js Middleware. It is called before a request is completed, and it receives an object with the auth
and request
properties. The auth
property contains the user's session, and the request
property contains the incoming request.here you're initializing NextAuth.js with the
authConfig
object and exporting the auth
property. You're also using the matcher
option from Middleware to specify that it should run on specific paths.The advantage of employing Middleware for this task is that the protected routes will not even start rendering until the Middleware verifies the authentication, enhancing both the security and performance of your application.
⇒미들웨어를 사용하면 미들웨어가 인증을 확인할 때까지 보호된 경로가 렌더링을 시작하지 않아 애플리케이션의 보안과 성능이 모두 향상된다는 이점이 있습니다.
뒤로