Skip to content

Commit 0afc868

Browse files
committed
fix(examples): use 'as unknown as' for NextRequest type casting
1 parent 9eefbe6 commit 0afc868

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

examples/nextjs-app-router-custom-components/middleware.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const oryPathPrefixes = [
3131
export async function middleware(request: NextRequest) {
3232
// Type cast needed due to Next.js version differences between packages
3333
const oryResponse = await oryMiddleware(
34-
request as Parameters<typeof oryMiddleware>[0],
34+
request as unknown as Parameters<typeof oryMiddleware>[0],
3535
)
3636

3737
const isOryPath = oryPathPrefixes.some((prefix) =>
@@ -43,8 +43,8 @@ export async function middleware(request: NextRequest) {
4343

4444
const response = NextResponse.next()
4545
const result = await csrfProtect(
46-
request as Parameters<typeof csrfProtect>[0],
47-
response as Parameters<typeof csrfProtect>[1],
46+
request as unknown as Parameters<typeof csrfProtect>[0],
47+
response as unknown as Parameters<typeof csrfProtect>[1],
4848
)
4949
if (!result.success) {
5050
return NextResponse.json(

examples/nextjs-pages-router/middleware.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const oryPathPrefixes = [
3131
export async function middleware(request: NextRequest) {
3232
// Type cast needed due to Next.js version differences between packages
3333
const oryResponse = await oryMiddleware(
34-
request as Parameters<typeof oryMiddleware>[0],
34+
request as unknown as Parameters<typeof oryMiddleware>[0],
3535
)
3636

3737
const isOryPath = oryPathPrefixes.some((prefix) =>
@@ -43,8 +43,8 @@ export async function middleware(request: NextRequest) {
4343

4444
const response = NextResponse.next()
4545
const result = await csrfProtect(
46-
request as Parameters<typeof csrfProtect>[0],
47-
response as Parameters<typeof csrfProtect>[1],
46+
request as unknown as Parameters<typeof csrfProtect>[0],
47+
response as unknown as Parameters<typeof csrfProtect>[1],
4848
)
4949
if (!result.success) {
5050
return NextResponse.json(

0 commit comments

Comments
 (0)