Skip to content

Commit

Permalink
feat: update middleware config
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorusclarence committed Feb 11, 2023
1 parent d29e348 commit c03f562
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
14 changes: 13 additions & 1 deletion src/pages/_middleware.ts → src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import { NextRequest, NextResponse } from 'next/server';

import { getUrlBySlug } from '@/lib/notion';
import { getAllLinkCategories, getUrlBySlug } from '@/lib/notion';

export default async function middleware(req: NextRequest) {
if (req.nextUrl.pathname.startsWith('/c/')) {
const path = req.nextUrl.pathname.split('/')[2];

const categories = await getAllLinkCategories();

if (categories.includes(path)) {
return;
} else {
return NextResponse.redirect('/404');
}
}

const path = req.nextUrl.pathname.split('/')[1];
const whitelist = [
'favicons',
Expand Down
15 changes: 0 additions & 15 deletions src/pages/c/_middleware.ts

This file was deleted.

1 comment on commit c03f562

@vercel
Copy link

@vercel vercel bot commented on c03f562 Feb 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.