-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91ef3f9
commit 667421f
Showing
4 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
crates/next-dev-tests/tests/integration/next/middleware/basic/input/middleware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// middleware.ts | ||
import { NextResponse } from "next/server"; | ||
import type { NextRequest } from "next/server"; | ||
|
||
export function middleware(request: NextRequest) { | ||
return NextResponse.redirect(new URL("/about-2", request.url)); | ||
} | ||
|
||
export const config = { | ||
matcher: "/about/:path*", | ||
}; |
17 changes: 17 additions & 0 deletions
17
crates/next-dev-tests/tests/integration/next/middleware/basic/input/pages/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useEffect } from "react"; | ||
|
||
export default function Home() { | ||
useEffect(() => { | ||
// Only run on client | ||
import("@turbo/pack-test-harness").then(runTests); | ||
}); | ||
|
||
return null; | ||
} | ||
|
||
function runTests() { | ||
it("should allow redirects to other paths", async () => { | ||
const res = await fetch("/about/hello"); | ||
expect(res.url.endsWith("/about-2")); | ||
}); | ||
} |