-
Notifications
You must be signed in to change notification settings - Fork 0
/
middleware.ts
33 lines (27 loc) · 924 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
import { NextRequest, NextResponse } from "next/server";
import { MiddlewareResolver } from "@/middleware/MiddlewareResolver";
import MiddlewareRegistry from "@/middleware/MiddlewareRegistry";
export async function middleware( request: NextRequest ) {
let response = NextResponse.next();
/**
* Sometimes I have a strange problem that the middleware won't fire for
* every page refresh.
*/
//response.headers.append("x-middleware-cache", "no-cache");
/**
* The response is being passed on to all defined middleware.
*/
return await MiddlewareResolver(MiddlewareRegistry, request, response);
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
*/
'/((?!api|_next/static|_next/image|favicon.ico).*)'
],
}