Client-side navigation and rewrites #13721
Unanswered
Thms-Brnrd
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi ! 👋
I try to build a Next.js app to display data about shows and episodes.
The app can be accessed at https://shows-list.now.sh, but some shows can be accessed by a specific URL. For example, https://awesome-show.now.sh display data about the show awesome-show.
[showSlug].js
display data of a given show[showSlug]/[episodeSlug].js
display data of a given episode of the showhttps://awesome-show.now.sh
is in some way an alias tohttps://shows-list.now.sh/awesome-show
https://awesome-show.now.sh/awesome-episode
is an alias tohttps://shows-list.now.sh/awesome-show/awesome-episode
I configured Vercel to rewrites request from
https://awesome-show.now.sh
tohttps://shows-list.now.sh/awesome-show
:This work greats for direct request but I try to add client-side navigation with those considerations.
Bascially, for
https://awesome-show.now.sh
, I try to add links to the page[showSlug]/[episodeSlug]
without having the full URL/awesome-show/episode1
but only/episode1
.Using
next/link
, I tried this but have an error due tohref
andas
mismatch :I found a workaround to this error, based on the PR #9837, navigation is done to the correct page, the URL is good but props passed to the page are wrong :
episode2
is passed as the propshowSlug
instead ofepisodeSlug
andepisodeSlug
is undefined.How to perform client-side navigation with this usage of
rewrites
? Is there a way to achieve this withnext/link
? If not, what are the alternatives to have the same behaviour (one domain to a global Next.js app + specific domain to a sub-section of the app) ?If needed, the code of
https://shows-list.now.sh
is accessible at https://github.com/Thms-Brnrd/shows-list andhttps://awesome-show.now.sh
at https://github.com/Thms-Brnrd/awesome-show.Thank you ! 😄
Beta Was this translation helpful? Give feedback.
All reactions