Update URL pattern in middleware

This change updates the URL patterns for 'admin', 'auth', and 'home' in the middleware file. The updated patterns now include a trailing wildcard and a questioning mark to match any potential following routes, which makes routing more flexible and accurate.
This commit is contained in:
gbuomprisco
2024-07-06 16:01:47 +08:00
parent bda79d41c0
commit 57f9d4364c

View File

@@ -132,11 +132,11 @@ async function adminMiddleware(request: NextRequest, response: NextResponse) {
function getPatterns() {
return [
{
pattern: new URLPattern({ pathname: '/admin*' }),
pattern: new URLPattern({ pathname: '/admin/*?' }),
handler: adminMiddleware,
},
{
pattern: new URLPattern({ pathname: '/auth*' }),
pattern: new URLPattern({ pathname: '/auth/*?' }),
handler: async (req: NextRequest, res: NextResponse) => {
const {
data: { user },
@@ -160,7 +160,7 @@ function getPatterns() {
},
},
{
pattern: new URLPattern({ pathname: '/home*' }),
pattern: new URLPattern({ pathname: '/home/*?' }),
handler: async (req: NextRequest, res: NextResponse) => {
const {
data: { user },