File tree Expand file tree Collapse file tree 4 files changed +490
-4
lines changed Expand file tree Collapse file tree 4 files changed +490
-4
lines changed Original file line number Diff line number Diff line change
1
+ import { NextResponse } from 'next/server'
2
+ import type { NextRequest } from 'next/server'
3
+
4
+ export async function middleware ( req : NextRequest ) {
5
+ const res = NextResponse . rewrite ( new URL ( '/' , req . url ) )
6
+ res . headers . set ( 'x-response-header' , 'set in middleware' )
7
+ res . headers . set ( 'x-is-deno' , 'Deno' in globalThis ? 'true' : 'false' )
8
+ return res
9
+ }
10
+
11
+ export const config = {
12
+ matcher : [ '/foo' ] ,
13
+ }
Original file line number Diff line number Diff line change
1
+ import { NextResponse } from 'next/server'
2
+ import type { NextRequest } from 'next/server'
3
+
4
+ export async function middleware ( req : NextRequest ) {
5
+ const res = NextResponse . rewrite ( new URL ( '/' , req . url ) )
6
+ res . headers . set ( 'x-response-header' , 'set in middleware' )
7
+ res . headers . set ( 'x-is-deno' , 'Deno' in globalThis ? 'true' : 'false' )
8
+ return res
9
+ }
10
+
11
+ export const config = {
12
+ matcher : [
13
+ '/foo' ,
14
+ { source : '/bar' } ,
15
+ {
16
+ source : '/baz' ,
17
+ has : [
18
+ {
19
+ type : 'header' ,
20
+ key : 'x-my-header' ,
21
+ value : 'my-value' ,
22
+ } ,
23
+ ] ,
24
+ } ,
25
+ {
26
+ source : '/en/asdf' ,
27
+ locale : false ,
28
+ } ,
29
+ ] ,
30
+ }
Original file line number Diff line number Diff line change 11
11
"private" : true ,
12
12
"dependencies" : {
13
13
"ms" : " 2.1.3" ,
14
- "next" : " ^12.3.0 " ,
14
+ "next" : " ^12.2.1 " ,
15
15
"react" : " ^18.0.0" ,
16
16
"react-dom" : " ^18.0.0"
17
17
},
24
24
"npm-run-all" : " ^4.1.5" ,
25
25
"typescript" : " ^4.6.3"
26
26
}
27
- }
27
+ }
You can’t perform that action at this time.
0 commit comments