This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
generated from acmutd/hackportal
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmiddleware.ts
76 lines (71 loc) · 1.76 KB
/
middleware.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { NextResponse } from 'next/server';
import { NextRequest } from 'next/server';
import { get } from '@vercel/edge-config';
// This function can be marked `async` if using `await` inside
export default async function middleware(request: NextRequest) {
const url = request.nextUrl;
switch (request.nextUrl.pathname) {
case '/judges':
case '/judge':
return NextResponse.redirect('https://go.rowdyhacks.org/judge');
break;
case '/mentors':
case '/mentor':
return NextResponse.redirect('https://go.rowdyhacks.org/mentor');
break;
case '/volunteers':
case '/schedule':
if (
(await get('allowViewSchedule')) === true ||
process.env.NEXT_PUBLIC_IS_STAGED_PROD == 'true'
) {
return NextResponse.next();
break;
}
url.pathname = '/404';
return NextResponse.rewrite(url);
case '/dashboard':
if (
(await get('allowViewDashboard')) === true ||
process.env.NEXT_PUBLIC_IS_STAGED_PROD == 'true'
) {
return NextResponse.next();
break;
}
url.pathname = '/404';
return NextResponse.rewrite(url);
case '/music':
if (
(await get('enableHackPortalMusicClient')) === true ||
process.env.NEXT_PUBLIC_IS_STAGED_PROD == 'true'
) {
return NextResponse.next();
break;
}
url.pathname = '/404';
return NextResponse.rewrite(url);
case '/volunteer':
return NextResponse.redirect('https://go.rowdyhacks.org/volunteer');
break;
case '/guide':
return NextResponse.redirect('https://guide.rowdyhacks.org/');
default:
return NextResponse.next();
break;
}
}
// See "Matching Paths" below to learn more
export const config = {
matcher: [
'/judges',
'/mentors',
'/mentor',
'/judge',
'/volunteer',
'/volunteers',
'/music',
'/schedule',
'/dashboard',
'/guide',
],
};