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
Add in getServerSideProps's function a parameter similar to asPath from getInitialProps, which would contain the URL path the user will see in it's browser.
Use cases include path logging and dynamic path analysis.
Describe the solution you'd like
For a file ./pages/items-search/[[...slug]].js, this parameter would show what the user will see after getServerSideProps returns, such as:
The parameter does not need to be necessarily named asPath.
Describe alternatives you've considered
It is technically possible to build the desired value by joining the folders+file name with the slug parameters and querystring.
It works, but I didn't find an easy way of dynamically retrieving the current path prefix (i.e. folders+file name, without including slug parameters or querystring). req.url can help, but it becomes something like /_next/data/BUILD_ID/PAGE_NAME.json?a=b during CSR requests.
The text was updated successfully, but these errors were encountered:
This continues off of #17081 and provides this normalized `asPath` value in the context provided to `getServerSideProps` to provide the consistent value since the request URL can vary between direct visit and client transition and the alternative requires building the URL each time manually.
Kept this change separate from #17081 since this is addressing a separate issue and allows discussion separately.
Closes: #16407
This continues off of vercel#17081 and provides this normalized `asPath` value in the context provided to `getServerSideProps` to provide the consistent value since the request URL can vary between direct visit and client transition and the alternative requires building the URL each time manually.
Kept this change separate from vercel#17081 since this is addressing a separate issue and allows discussion separately.
Closes: vercel#16407
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 29, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Feature request
Add in
getServerSideProps
's function a parameter similar toasPath
fromgetInitialProps
, which would contain the URL path the user will see in it's browser.Use cases include path logging and dynamic path analysis.
Describe the solution you'd like
For a file
./pages/items-search/[[...slug]].js
, this parameter would show what the user will see aftergetServerSideProps
returns, such as:/items-search/
/items-search/?order=asc
/items-search/category-one/
/items-search/category-one/sub-category-two/
/items-search/category-one/?order=asc
/items-search/category-one/sub-category-two/?order=desc&query=super%20item
The parameter does not need to be necessarily named
asPath
.Describe alternatives you've considered
It is technically possible to build the desired value by joining the folders+file name with the slug parameters and querystring.
It works, but I didn't find an easy way of dynamically retrieving the current path prefix (i.e. folders+file name, without including slug parameters or querystring).
req.url
can help, but it becomes something like/_next/data/BUILD_ID/PAGE_NAME.json?a=b
during CSR requests.The text was updated successfully, but these errors were encountered: