File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1+ import { getTeams } from "@/api/team" ;
12import { isLoginRequired } from "@/constants/auth" ;
23import { COOKIE_ACTIVE_ACCOUNT , COOKIE_PREFIX_TOKEN } from "@/constants/cookie" ;
34import { type NextRequest , NextResponse } from "next/server" ;
@@ -93,6 +94,18 @@ export async function middleware(request: NextRequest) {
9394 return rewrite ( request , `/published-contract${ pathname } ` ) ;
9495 }
9596 }
97+
98+ // redirect /team/~/... to /team/<first_team_slug>/...
99+ if ( paths [ 0 ] === "team" && paths [ 1 ] === "~" ) {
100+ // TODO - need an API to get the first team to avoid fetching all teams
101+ const teams = await getTeams ( ) ;
102+ const firstTeam = teams [ 0 ] ;
103+ if ( firstTeam ) {
104+ const modifiedPaths = [ ...paths ] ;
105+ modifiedPaths [ 1 ] = firstTeam . slug ;
106+ return redirect ( request , `/${ modifiedPaths . join ( "/" ) } ` ) ;
107+ }
108+ }
96109 // END /<address>/... case
97110 // all other cases are handled by the file system router so we just fall through
98111}
You can’t perform that action at this time.
0 commit comments