Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET-query params are lost when using unstable_getStaticProps in production mode #9732

Closed
khades opened this issue Dec 13, 2019 · 3 comments · Fixed by #9734
Closed

GET-query params are lost when using unstable_getStaticProps in production mode #9732

khades opened this issue Dec 13, 2019 · 3 comments · Fixed by #9734
Assignees
Milestone

Comments

@khades
Copy link
Contributor

khades commented Dec 13, 2019

GET-query params are lost when using unstable_getStaticProps in production mode

In DEV-mode when i do request to a page with GET-query parameters, i can read them in unstable_getStaticProps.

Example:

file pages/[category].jsx

...
export async function unstable_getStaticProps({params}) {
    // while doing request to http://localhost:8000/items?page=13
    // category is always "items"
    // "params" is 13 in DEV mode, but undefined in production mode
    const {category, page} = params;
}

Meanwhile after build GET-query parameters are not added to params due to code on that line:

https://github.com/zeit/next.js/blob/88de2328e532eaf0cbb860957f8a5bc2d4c82c44/packages/next/next-server/server/next-server.ts#L917

Judging by the code, GET-query parameters are actually got parsed, but are thrown away.

I checked that out by replacing line
https://github.com/zeit/next.js/blob/88de2328e532eaf0cbb860957f8a5bc2d4c82c44/packages/next/next-server/server/next-server.ts#L919
with code

 result.unstable_getStaticProps ? Object.assign({}, query, params): params

I am sure that's not the right way to fix it, but it did show to me there's bug in L917.

This is reproducable on next 9.1.4 and canary 9.1.6

@Timer
Copy link
Member

Timer commented Dec 13, 2019

Hey! Query string information is not available in getStaticProps.

The bug we need to fix is that it was available in development -- production is working properly.

Thanks for reporting!

@khades
Copy link
Contributor Author

khades commented Dec 14, 2019

Oh, i was using it as a feature. That's sad

@balazsorban44
Copy link
Member

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 vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants