mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
improvement(middleware): added /w to route to /w/1
This commit is contained in:
+10
-1
@@ -2,6 +2,12 @@ import { NextRequest, NextResponse } from 'next/server'
|
||||
import { getSessionCookie } from 'better-auth'
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
// Check if the path is exactly /w
|
||||
if (request.nextUrl.pathname === '/w') {
|
||||
return NextResponse.redirect(new URL('/w/1', request.url))
|
||||
}
|
||||
|
||||
// Existing auth check for protected routes
|
||||
const sessionCookie = getSessionCookie(request)
|
||||
if (!sessionCookie) {
|
||||
return NextResponse.redirect(new URL('/login', request.url))
|
||||
@@ -11,5 +17,8 @@ export async function middleware(request: NextRequest) {
|
||||
|
||||
// TODO: Add protected routes
|
||||
export const config = {
|
||||
matcher: ['/w/:path*'],
|
||||
matcher: [
|
||||
'/w', // Match exactly /w
|
||||
'/w/:path*', // Keep existing matcher for protected routes
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user