Skip to content

Commit fb2af2f

Browse files
committed
fix: updatiing demo to showcase missing matcher
1 parent 5de27e1 commit fb2af2f

File tree

3 files changed

+303
-1
lines changed

3 files changed

+303
-1
lines changed

demos/middleware/middleware.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export async function middleware(req: NextRequest) {
5656
if (pathname.startsWith('/cookies')) {
5757
response = NextResponse.next()
5858
response.cookies.set('netlifyCookie', 'true')
59+
response.cookies.set('missingCookie', 'true')
5960
return response
6061
}
6162

@@ -66,6 +67,12 @@ export async function middleware(req: NextRequest) {
6667
return response
6768
}
6869

70+
if (pathname.startsWith('/missing')) {
71+
response = NextResponse.next()
72+
response.headers.set('x-cookie-missing', 'true')
73+
return response
74+
}
75+
6976
if (pathname.startsWith('/shows')) {
7077
if (pathname.startsWith('/shows/222')) {
7178
response = NextResponse.next()
@@ -130,5 +137,14 @@ export const config = {
130137
},
131138
],
132139
},
140+
{
141+
source: '/missing',
142+
missing: [
143+
{
144+
type: 'cookie',
145+
key: 'missingCookie',
146+
}
147+
],
148+
},
133149
],
134150
}

demos/middleware/pages/missing.js

Lines changed: 13 additions & 0 deletions
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="/cookies">cookies page</Link> and come back</p>
9+
</div>
10+
)
11+
}
12+
13+
export default Missing

package-lock.json

Lines changed: 274 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)