@@ -83,6 +83,21 @@ export async function middleware(request: NextRequest) {
8383 return NextResponse . redirect ( new URL ( '/login' , request . url ) )
8484 }
8585
86+ // Handle whitelabel redirects for terms and privacy pages
87+ if ( url . pathname === '/terms' ) {
88+ const termsUrl = process . env . NEXT_PUBLIC_TERMS_URL
89+ if ( termsUrl ?. startsWith ( 'http' ) ) {
90+ return NextResponse . redirect ( termsUrl )
91+ }
92+ }
93+
94+ if ( url . pathname === '/privacy' ) {
95+ const privacyUrl = process . env . NEXT_PUBLIC_PRIVACY_URL
96+ if ( privacyUrl ?. startsWith ( 'http' ) ) {
97+ return NextResponse . redirect ( privacyUrl )
98+ }
99+ }
100+
86101 // Legacy redirect: /w -> /workspace (will be handled by workspace layout)
87102 if ( url . pathname === '/w' || url . pathname . startsWith ( '/w/' ) ) {
88103 // Extract workflow ID if present
@@ -195,6 +210,8 @@ export async function middleware(request: NextRequest) {
195210export const config = {
196211 matcher : [
197212 '/' , // Root path for self-hosted redirect logic
213+ '/terms' , // Whitelabel terms redirect
214+ '/privacy' , // Whitelabel privacy redirect
198215 '/w' , // Legacy /w redirect
199216 '/w/:path*' , // Legacy /w/* redirects
200217 '/workspace/:path*' , // New workspace routes
0 commit comments