This repo reproduces a strange behaviour of the Next.js standalone
mode. Rewrites with destination /index/
do not work as expected, however rewrites with other destinations (e.g. /test/
) do work.
The same behavior occurs in combination with a middleware.js
file. The rewrite is executed but the query param is not set (/test-middleware/
should redirect to /index/
too).
/
should rewrite to/index/
and the query params should be set accordingly./test-middleware
should rewrite to/index/
and the query params should be set accordingly.
npm run dev
ornpm run build && npm run start
: The rewrite works: The query params forslug
are set correctly.npm run build && cp -r public .next/standalone && cp -r .next/static .next/standalone/.next && node .next/standalone/server.js
: The rewrite does not work, the query param forslug
does not exist.
- Visit http://localhost:3000/ the query should contain the slug
index
as seen below.
{
"query": {
"slug": [
"index"
]
},
"resolvedUrl": "/index"
}
- Visit http://localhost:3000/test-middleware/ the query should contain the slug
index
.
{
"query": {
"slug": [
"index"
]
},
"resolvedUrl": "/index"
}