diff --git a/test/e2e/as-path-with-rewrites/as-path-with-rewrites.test.ts b/test/e2e/as-path-with-rewrites/as-path-with-rewrites.test.ts
deleted file mode 100644
index ad5b51c3d34c4..0000000000000
--- a/test/e2e/as-path-with-rewrites/as-path-with-rewrites.test.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { nextTestSetup } from 'e2e-utils'
-
-describe('as-path-with-rewrites', () => {
- const { next } = nextTestSetup({
- files: __dirname,
- })
-
- it('should not include internal query params in `asPath` and `req.url`', async () => {
- const $ = await next.render$('/foo')
- expect($('#as-path').text()).toBe('/foo')
- expect($('#req-url').text()).toBe('/foo')
- })
-})
diff --git a/test/e2e/as-path-with-rewrites/next.config.js b/test/e2e/as-path-with-rewrites/next.config.js
deleted file mode 100644
index dfd05fcccd917..0000000000000
--- a/test/e2e/as-path-with-rewrites/next.config.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/** @type {import('next').NextConfig} */
-const nextConfig = {
- async rewrites() {
- return [
- {
- source: '/:path+',
- missing: [
- {
- type: 'host',
- value: 'example.com',
- },
- ],
- destination: '/rewrite-target',
- },
- ]
- },
-}
-
-module.exports = nextConfig
diff --git a/test/e2e/as-path-with-rewrites/pages/index.tsx b/test/e2e/as-path-with-rewrites/pages/index.tsx
deleted file mode 100644
index b388f78365655..0000000000000
--- a/test/e2e/as-path-with-rewrites/pages/index.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { GetServerSidePropsContext } from 'next'
-import { useRouter } from 'next/router'
-import React from 'react'
-
-export async function getServerSideProps(context: GetServerSidePropsContext) {
- return { props: {} }
-}
-
-export default function Page() {
- const router = useRouter()
-
- return
home: {router.asPath}
-}
diff --git a/test/e2e/getserversideprops/app/next.config.js b/test/e2e/getserversideprops/app/next.config.js
index ac7d2bcaf0a93..ef7ab634dc3fc 100644
--- a/test/e2e/getserversideprops/app/next.config.js
+++ b/test/e2e/getserversideprops/app/next.config.js
@@ -14,6 +14,10 @@ module.exports = {
source: '/blog-:param',
destination: '/blog/post-3',
},
+ {
+ source: '/rewrite-source/:path+',
+ destination: '/rewrite-target',
+ },
]
},
}
diff --git a/test/e2e/getserversideprops/app/pages/index.js b/test/e2e/getserversideprops/app/pages/index.js
index cb0367080de5d..f58eef648868f 100644
--- a/test/e2e/getserversideprops/app/pages/index.js
+++ b/test/e2e/getserversideprops/app/pages/index.js
@@ -95,6 +95,8 @@ const Page = ({ world, time, url }) => {
to redirect-page
+
+ to rewrite-source/foo
>
)
}
diff --git a/test/e2e/as-path-with-rewrites/pages/rewrite-target/index.tsx b/test/e2e/getserversideprops/app/pages/rewrite-target/index.js
similarity index 56%
rename from test/e2e/as-path-with-rewrites/pages/rewrite-target/index.tsx
rename to test/e2e/getserversideprops/app/pages/rewrite-target/index.js
index ebf65b51d312e..d74fbbd7458aa 100644
--- a/test/e2e/as-path-with-rewrites/pages/rewrite-target/index.tsx
+++ b/test/e2e/getserversideprops/app/pages/rewrite-target/index.js
@@ -1,11 +1,10 @@
-import { GetServerSidePropsContext } from 'next'
import { useRouter } from 'next/router'
-export async function getServerSideProps({ req }: GetServerSidePropsContext) {
+export async function getServerSideProps({ req }) {
return { props: { url: req.url } }
}
-export default function RewriteTarget({ url }: { url: string }) {
+export default function RewriteTarget({ url }) {
const router = useRouter()
return (
diff --git a/test/e2e/getserversideprops/test/index.test.ts b/test/e2e/getserversideprops/test/index.test.ts
index b0957855a4ae0..15ec00f08ddf1 100644
--- a/test/e2e/getserversideprops/test/index.test.ts
+++ b/test/e2e/getserversideprops/test/index.test.ts
@@ -543,6 +543,13 @@ const runTests = (isDev = false, isDeploy = false) => {
expect($('#as-path').text()).toBe('/something')
})
+ it('should not include rewrite query params in `asPath` and `req.url`', async () => {
+ const $ = await next.render$('/rewrite-source/foo')
+ expect($('h1').text()).toBe('rewrite-target')
+ expect($('#as-path').text()).toBe('/rewrite-source/foo')
+ expect($('#req-url').text()).toBe('/rewrite-source/foo')
+ })
+
it('should return data correctly', async () => {
const data = JSON.parse(
await renderViaHTTP(next.url, `/_next/data/${buildId}/something.json`)