/
githubmirror
/
marktext
Обзор
Документация
Войти
/
githubmirror
/
marktext
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/website/src/middleware.ts
20 строк
802 B
Ran Luo
chore(website): tighten middleware matcher; drop unused 'use client' (#4351)
02 июн 2026, 19:38
Не верифицирован
02 июн 2026, 19:38
4fe7e06
Код
Авторство
О чём код?
import { NextResponse, type NextRequest } from 'next/server' // 301 www.marktext.me/* -> marktext.me/* so SEO indexes a single canonical // host. We do this in middleware rather than next.config.ts redirects() // because OpenNext Cloudflare does not currently substitute Next's `:path*` // destination tokens, which sends users to the literal /:path* URL (404). export function middleware(req: NextRequest) { if (req.headers.get('host')?.toLowerCase() !== 'www.marktext.me') return const url = req.nextUrl.clone() url.host = 'marktext.me' url.protocol = 'https:' url.port = '' return NextResponse.redirect(url, 301) } export const config = { matcher: [ '/((?!_next/static|_next/image|favicon\\.ico|favicon\\.png|sitemap\\.xml|robots\\.txt|docs-index\\.json|assets/|docs/).*)' ] }