Openstatus www.openstatus.dev

๐Ÿ› invitation (#819)

authored by

Thibault Le Ouay and committed by
GitHub
ae38510c eb276eb9

+19 -2
+19 -2
apps/web/src/middleware.ts
··· 33 33 return subdomain; 34 34 }; 35 35 36 - const publicAppPaths = ["/app/sign-in", "/app/sign-up", "/app/login"]; 36 + const publicAppPaths = [ 37 + "/app/sign-in", 38 + "/app/sign-up", 39 + "/app/login", 40 + "/app/invite", 41 + ]; 37 42 38 43 // remove auth middleware if needed 39 44 // export const middleware = () => NextResponse.next(); ··· 60 65 pathname.startsWith(path), 61 66 ); 62 67 68 + if (!req.auth && pathname.startsWith("/app/invite")) { 69 + return NextResponse.redirect( 70 + new URL( 71 + `/app/login?redirectTo=${encodeURIComponent(req.nextUrl.href)}`, 72 + req.url, 73 + ), 74 + ); 75 + } 76 + 63 77 if (!req.auth && pathname.startsWith("/app") && !isPublicAppPath) { 64 78 return NextResponse.redirect( 65 - new URL(`/app/login?redirectTo=${encodeURIComponent(pathname)}`, req.url), 79 + new URL( 80 + `/app/login?redirectTo=${encodeURIComponent(req.nextUrl.href)}`, 81 + req.url, 82 + ), 66 83 ); 67 84 } 68 85