Skip to content

Commit 9fd63e9

Browse files
authored
Merge branch 'main' into sma/docs-migration-cleanup
2 parents c3a28f8 + f30e178 commit 9fd63e9

File tree

8 files changed

+457
-42
lines changed

8 files changed

+457
-42
lines changed

demos/middleware/middleware.ts

+22
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,25 @@ export async function middleware(req: NextRequest) {
5959
return response
6060
}
6161

62+
if(pathname.startsWith('/matcher-cookie')) {
63+
response = NextResponse.next()
64+
response.cookies.set('missingCookie', 'true')
65+
return response
66+
}
67+
6268
if (pathname.startsWith('/conditional')) {
6369
response = NextResponse.next()
6470
response.headers.set('x-modified-edge', 'true')
6571
response.headers.set('x-is-deno', 'Deno' in globalThis ? 'true' : 'false')
6672
return response
6773
}
6874

75+
if (pathname.startsWith('/missing')) {
76+
response = NextResponse.next()
77+
response.headers.set('x-cookie-missing', 'true')
78+
return response
79+
}
80+
6981
if (pathname.startsWith('/shows')) {
7082
if (pathname.startsWith('/shows/222')) {
7183
response = NextResponse.next()
@@ -119,6 +131,7 @@ export const config = {
119131
'/headers',
120132
{ source: '/static' },
121133
{ source: '/cookies' },
134+
{ source: '/matcher-cookie'},
122135
{ source: '/shows/((?!99|88).*)' },
123136
{
124137
source: '/conditional',
@@ -130,5 +143,14 @@ export const config = {
130143
},
131144
],
132145
},
146+
{
147+
source: '/missing',
148+
missing: [
149+
{
150+
type: 'cookie',
151+
key: 'missingCookie',
152+
}
153+
],
154+
},
133155
],
134156
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const MatcherCookie = () => {
2+
return (
3+
<div>
4+
<p>The cookie "missingCookie" should be set to true</p>
5+
</div>
6+
)
7+
}
8+
9+
export default MatcherCookie

demos/middleware/pages/missing.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as React from 'react'
2+
import Link from 'next/link'
3+
4+
const Missing = () => {
5+
return (
6+
<div>
7+
<p>Will Check if 'missingCookie' is missing and display headers</p>
8+
<p>To test go to <Link href="/matcher-cookie">cookies page</Link> and come back</p>
9+
</div>
10+
)
11+
}
12+
13+
export default Missing

0 commit comments

Comments
 (0)