Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
refactor: simplify middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
agustinusnathaniel committed Nov 29, 2023
1 parent c66efd9 commit 9cc0cdd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/lib/constants/paths.ts

This file was deleted.

7 changes: 4 additions & 3 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';

import { env } from '~/lib/constants/env';
import { funPaths } from '~/lib/constants/paths';

const funPath = 'why-i';

export const middleware = async (req: NextRequest) => {
const isFunPath = !!funPaths.find((item) => req.nextUrl.href.includes(item));
const isFunPath = !!req.nextUrl.href.includes(funPath);

if (isFunPath) {
return NextResponse.redirect(env.MM_URL);
Expand All @@ -29,7 +30,7 @@ export const middleware = async (req: NextRequest) => {
export const config = {
matcher: [
'/((?!api|_next/static|_next/image|favicon.ico|manifest.json|robots.txt).*)',
...funPaths.map((item) => `/${item}:path*`),
`/why-i:path*`,
'/s/:path*',
],
};

0 comments on commit 9cc0cdd

Please sign in to comment.