Skip to content

Commit 0aaa3ac

Browse files
committed
refactor: remove duplicate route conditional
1 parent 1c22522 commit 0aaa3ac

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

demos/middleware/middleware.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function middleware(req: NextRequest) {
1212
// Next 13 request header mutation functionality
1313
const headers = new Headers(req.headers)
1414
debugger;
15-
headers.set('x-from-middleware', 'hello-from-middleware')
15+
headers.set('x-hello', 'world')
1616
return NextResponse.next({
1717
request: {
1818
headers
@@ -36,12 +36,6 @@ export async function middleware(req: NextRequest) {
3636
return res
3737
}
3838

39-
if (pathname.startsWith('/api/hello')) {
40-
// Add a header to the request
41-
req.headers.set('x-hello', 'world')
42-
return request.next()
43-
}
44-
4539
if (pathname.startsWith('/api/geo')) {
4640
req.headers.set('x-geo-country', req.geo.country)
4741
req.headers.set('x-geo-region', req.geo.region)

0 commit comments

Comments
 (0)