-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmiddleware.ts
34 lines (29 loc) · 993 Bytes
/
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
import { ratelimit } from "@/lib/rateLimit";
import getIP from "@/utils";
import {
type NextFetchEvent,
type NextRequest,
NextResponse,
} from "next/server";
export default async function middleware(
request: NextRequest,
event: NextFetchEvent
): Promise<Response | undefined> {
// // limit the request based on the IP
// const { success, limit, reset, remaining } = await ratelimit.limit(
// `ratelimit_middleware_${getIP(request)}`
// );
// // if the request isn't rate limited, continue
// const res =
// success || process.env.NEXT_PUBLIC_DEVELOPMENT === "true"
// ? NextResponse.next()
// : NextResponse.redirect(new URL("/api/blocked", request.url));
// res.headers.set("X-RateLimit-Limit", limit.toString());
// res.headers.set("X-RateLimit-Remaining", remaining.toString());
// res.headers.set("X-RateLimit-Reset", reset.toString());
// return res;
return NextResponse.next();
}
export const config = {
matcher: "/api/(.*)",
};