mirror of
https://github.com/penxio/penx.git
synced 2026-04-19 03:03:06 -04:00
chore: rm middleware
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user