chore: rm middleware

This commit is contained in:
0xzio
2024-10-25 00:08:01 +08:00
parent 0869e96602
commit 9e6eca2b09
3 changed files with 0 additions and 51 deletions

View File

@@ -1,7 +1,6 @@
import { ModeToggle } from '@/components/ModeToggle'
import { Profile } from '@/components/Profile/Profile'
import { getSite } from '@/lib/fetchers'
import { getSession } from '@/lib/getSession'
import { loadTheme } from '@/lib/loadTheme'
export const dynamic = 'force-static'

View File

@@ -1,6 +1,5 @@
import { GateType } from '@/lib/constants'
import { getPost, getPosts } from '@/lib/fetchers'
import { getSession } from '@/lib/getSession'
import { loadTheme } from '@/lib/loadTheme'
import { TipTapNode } from '@plantreexyz/types'
import { Post } from '@prisma/client'
@@ -28,8 +27,6 @@ export default async function Page({ params }: { params: { slug: string[] } }) {
const slug = decodeURI(params.slug.join('/'))
const [post, posts] = await Promise.all([getPost(slug), getPosts()])
const session = await getSession()
const postIndex = posts.findIndex((p) => p.slug === slug)
if (postIndex === -1 || !post) {
return notFound()

View File

@@ -1,47 +0,0 @@
import { getToken } from 'next-auth/jwt'
import { NextRequest, NextResponse } from 'next/server'
export const config = {
matcher: [
/*
* Match all paths except for:
* 1. /api routes
* 2. /_next (Next.js internals)
* 3. /_static (inside /public)
* 4. all root files inside /public (e.g. /favicon.ico)
*/
'/((?!api/|_next/|_static/|_vercel|[\\w-]+\\.\\w+).*)',
],
}
export default async function middleware(req: NextRequest) {
const url = req.nextUrl
const searchParams = req.nextUrl.searchParams.toString()
// Get the pathname of the request (e.g. /, /about, /blog/first-post)
const path = `${url.pathname}${
searchParams.length > 0 ? `?${searchParams}` : ''
}`
if (path.startsWith('/~')) {
const token = await getToken({ req })
console.log('=======token:', token)
if (!token) {
return NextResponse.redirect(new URL('/', req.url))
} else {
return NextResponse.next()
}
}
// if (path.startsWith('/~') ) {
// const token = await getToken({ req })
// if (!token) {
// return NextResponse.redirect(new URL('/login', req.url))
// }
// return NextResponse.rewrite(new URL(path, req.url))
// }
return NextResponse.next()
}