Skip to content

Commit 3c2789b

Browse files
committed
test: try running existing tests against node middleware
1 parent 661496b commit 3c2789b

File tree

12 files changed

+29
-2
lines changed

12 files changed

+29
-2
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
elif [ "${{ github.event_name }}" = "schedule" ] || [ "${{ steps.check-labels.outputs.result }}" = "true" ]; then
3939
echo "matrix=[\"latest\", \"canary\", \"14.2.15\", \"13.5.1\"]" >> $GITHUB_OUTPUT
4040
else
41-
echo "matrix=[\"latest\"]" >> $GITHUB_OUTPUT
41+
echo "matrix=[\"canary\"]" >> $GITHUB_OUTPUT
4242
fi
4343
4444
e2e:

tests/fixtures/middleware-conditions/middleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ export const config = {
2323
locale: false,
2424
},
2525
],
26+
runtime: 'nodejs',
2627
}

tests/fixtures/middleware-i18n-excluded-paths/middleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ export const config = {
3333
*/
3434
'/((?!api|excluded|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)',
3535
],
36+
runtime: 'nodejs',
3637
}

tests/fixtures/middleware-i18n-skip-normalize/middleware.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@ export async function middleware(request) {
8989
})
9090
}
9191
}
92+
93+
export const config = {
94+
runtime: 'nodejs',
95+
}

tests/fixtures/middleware-i18n/middleware.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,7 @@ export async function middleware(request) {
114114
})
115115
}
116116
}
117+
118+
export const config = {
119+
runtime: 'nodejs',
120+
}

tests/fixtures/middleware-node/middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { type NextRequest, NextResponse } from 'next/server'
22
import { join } from 'path'
33

44
export default async function middleware(req: NextRequest) {
5-
return NextResponse.json({ message: 'Hello, world!', joined: join('a', 'b') })
5+
const response = NextResponse.next()
6+
response.headers.set('x-added-middleware-headers-join', join('a', 'b'))
7+
return response
68
}
79

810
export const config = {

tests/fixtures/middleware-pages/middleware.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,7 @@ const params = (url) => {
123123
}
124124
return result
125125
}
126+
127+
export const config = {
128+
runtime: 'nodejs',
129+
}

tests/fixtures/middleware-src/src/middleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ const getResponse = (request: NextRequest) => {
2828

2929
export const config = {
3030
matcher: '/test/:path*',
31+
runtime: 'nodejs',
3132
}

tests/fixtures/middleware-static-asset-matcher/middleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export default function middleware() {
44

55
export const config = {
66
matcher: '/hello/world.txt',
7+
runtime: 'nodejs',
78
}

tests/fixtures/middleware-subrequest-vuln/middleware.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ export async function middleware(request: NextRequest) {
1111

1212
return response
1313
}
14+
15+
export const config = {
16+
runtime: 'nodejs',
17+
}

0 commit comments

Comments
 (0)