You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use Next.js' Rewrite feature. But when I put an array in a query part of a destination link string (in next.config.js), a context, that I receive in getServerSideProps, contains only first parameter of the array.
Open /projects page in a browser and check the server-side terminal
Actually, I've figured out why this happens and i'm ready to create PR. But before, I need to make sure that I understood the problem.
Here is the code, that causes the bug (packages/next/next-server/lib/router/utils/prepare-destination.ts):
export default function prepareDestination(
destination: string,
params: Params,
query: ParsedUrlQuery,
appendParamsToQuery: boolean
) {
...
// update any params in query values
for (const [key, strOrArray] of Object.entries(destQuery)) {
let value = Array.isArray(strOrArray) ? strOrArray[0] : strOrArray
if (value) {
// the value needs to start with a forward-slash to be compiled
// correctly
value = compileNonPath(value, params)
}
destQuery[key] = value
}
...
As you can see, it takes only a first item of the query array. I believe we must use.maphere
The text was updated successfully, but these errors were encountered:
lsndr
changed the title
Rewrite trasnforms array query parameters of destination link into strings
Rewrite transforms array parameters of query of destination link into strings
Jun 25, 2021
lsndr
changed the title
Rewrite transforms array parameters of query of destination link into strings
"Rewrite" transforms array parameters of query of destination link into strings
Jun 25, 2021
lsndr
changed the title
"Rewrite" transforms array parameters of query of destination link into strings
«Rewrite mechanism» transforms array parameters of query of destination link into strings
Jun 25, 2021
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
vercel
locked as resolved and limited conversation to collaborators
Jan 28, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Next.js are you using?
10.2.2
What version of Node.js are you using?
14.17.1
What browser are you using?
Safari
What operating system are you using?
macOS
How are you deploying your application?
next start
Describe the Bug
I'm trying to use Next.js' Rewrite feature. But when I put an array in a query part of a destination link string (in next.config.js), a context, that I receive in
getServerSideProps
, contains only first parameter of the array.Here is my next.config.js
When I open /projects in a browser, only first value of
tags
parameter is passed intocontext.query
ofgetServerSideProps
:Expected Behavior
context.query
ingetServerSideProps
must contain all query values.To Reproduce
/projects
page in a browser and check the server-side terminalActually, I've figured out why this happens and i'm ready to create PR. But before, I need to make sure that I understood the problem.
Here is the code, that causes the bug (packages/next/next-server/lib/router/utils/prepare-destination.ts):
As you can see, it takes only a first item of the query array. I believe we must use
.map
hereThe text was updated successfully, but these errors were encountered: