Skip to content

Commit 2575f04

Browse files
authored
Revert "fix cookie redirect matcher (#261)" (#267)
This reverts commit 8483dea.
1 parent 9e40c1a commit 2575f04

File tree

4 files changed

+2
-119
lines changed

4 files changed

+2
-119
lines changed

examples/app-router/app/config-redirect/page.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/app-router/next.config.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,6 @@ const nextConfig = {
88
experimental: {
99
serverActions: true,
1010
},
11-
redirects: () => {
12-
return [
13-
{
14-
source: "/next-config-redirect-missing",
15-
destination: "/config-redirect?missing=true",
16-
permanent: true,
17-
missing: [{ type: "cookie", key: "missing-cookie" }],
18-
},
19-
{
20-
source: "/next-config-redirect-not-missing",
21-
destination: "/config-redirect?missing=true",
22-
permanent: true,
23-
missing: [{ type: "cookie", key: "from" }], // middleware sets this cookie
24-
},
25-
{
26-
source: "/next-config-redirect-has",
27-
destination: "/config-redirect?has=true",
28-
permanent: true,
29-
has: [{ type: "cookie", key: "from" }],
30-
},
31-
{
32-
source: "/next-config-redirect-has-with-value",
33-
destination: "/config-redirect?hasWithValue=true",
34-
permanent: true,
35-
has: [{ type: "cookie", key: "from", value: "middleware" }],
36-
},
37-
{
38-
source: "/next-config-redirect-has-with-bad-value",
39-
destination: "/config-redirect?hasWithBadValue=true",
40-
permanent: true,
41-
has: [{ type: "cookie", key: "from", value: "wrongvalue" }],
42-
},
43-
];
44-
},
4511
headers() {
4612
return [
4713
{

packages/open-next/src/adapters/routing/matcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ const routeHasMatcher =
2222
switch (redirect.type) {
2323
case "header":
2424
return (
25-
!!headers?.[redirect.key.toLowerCase()] &&
25+
headers?.[redirect.key.toLowerCase()] !== "" &&
2626
new RegExp(redirect.value ?? "").test(
2727
headers[redirect.key.toLowerCase()] ?? "",
2828
)
2929
);
3030
case "cookie":
3131
return (
32-
!!cookies?.[redirect.key] &&
32+
cookies?.[redirect.key] !== "" &&
3333
new RegExp(redirect.value ?? "").test(cookies[redirect.key] ?? "")
3434
);
3535
case "query":

packages/tests-e2e/tests/appRouter/config.redirect.test.ts

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)