diff --git a/examples/pages-router/next.config.js b/examples/pages-router/next.config.js index 79370ecbf..66c213a22 100644 --- a/examples/pages-router/next.config.js +++ b/examples/pages-router/next.config.js @@ -5,7 +5,20 @@ const nextConfig = { reactStrictMode: true, output: "standalone", outputFileTracing: "../sst", - rewrites: () => [{ source: "/rewrite", destination: "/" }], + rewrites: () => [ + { source: "/rewrite", destination: "/" }, + { + source: "/rewriteUsingQuery", + destination: "/:destination/", + has: [ + { + type: "query", + key: "d", + value: "(?\\w+)", + }, + ], + }, + ], trailingSlash: true, }; diff --git a/packages/tests-e2e/tests/pagesRouter/rewrite.test.ts b/packages/tests-e2e/tests/pagesRouter/rewrite.test.ts index ba0c0b7ce..ad0b6fa2b 100644 --- a/packages/tests-e2e/tests/pagesRouter/rewrite.test.ts +++ b/packages/tests-e2e/tests/pagesRouter/rewrite.test.ts @@ -6,3 +6,10 @@ test("Single Rewrite", async ({ page }) => { let el = page.getByText("Nextjs Pages Router"); await expect(el).toBeVisible(); }); + +test("Rewrite with query", async ({ page }) => { + await page.goto("/rewriteUsingQuery?d=ssr"); + + let el = page.getByText("SSR"); + await expect(el).toBeVisible(); +});