MCPcopy Create free account
hub / github.com/SyntaxUI/syntaxui / middleware

Function middleware

src/middleware.ts:27–52  ·  view source on GitHub ↗
(request: NextRequest)

Source from the content-addressed store, hash-verified

25]
26
27export function middleware(request: NextRequest) {
28 const { pathname } = request.nextUrl
29
30 console.log('pathname', pathname)
31
32 // Redirect /docs directly to /components
33 if (pathname === '/docs') {
34 return NextResponse.redirect(new URL('/components', request.url))
35 }
36
37 // If any path starts with /docs, rewrite it by removing the /docs prefix
38 if (pathname.startsWith('/docs/')) {
39 const newPathname = pathname.replace('/docs', '')
40 return NextResponse.redirect(new URL(newPathname, request.url))
41 }
42
43 // Check if any redirects match the current path
44 for (const redirect of redirects) {
45 if (pathname.startsWith(redirect.from)) {
46 return NextResponse.redirect(new URL(redirect.to, request.url))
47 }
48 }
49
50 // Continue processing for other paths
51 return NextResponse.next()
52}
53
54// Applies to any route that starts with /docs or just /docs
55export const config = {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected