-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddleware.ts
More file actions
48 lines (43 loc) · 1.2 KB
/
middleware.ts
File metadata and controls
48 lines (43 loc) · 1.2 KB
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
import { withAuth } from "next-auth/middleware";
import { NextResponse } from "next/server";
export default withAuth(
function middleware() {
return NextResponse.next();
},
{
callbacks: {
authorized({ req, token }) {
const { pathname } = req.nextUrl;
if (
pathname.startsWith("/api/auth") ||
pathname === "/login" ||
pathname === "/register" ||
pathname === "/videos" ||
pathname === "/"
// remove few later
// pathname === "/feed" ||
// pathname === "/dashboard" ||
// pathname === "/upload" ||
// pathname.startsWith("/edit") ||
// pathname.startsWith("/details") ||
// pathname.startsWith("/api/videos")
) {
return true;
}
return !!token;
},
},
}
);
export const config = {
matcher: [
/*
* Match all request paths except:
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
* - public folder
*/
"/((?!api/videos/free-videos|_next/static|_next/image|favicon.ico|.*\\.(?:jpg|jpeg|png|gif|webp|svg|mp4|webm|ogg)$).*)",
],
};