-
-
Notifications
You must be signed in to change notification settings - Fork 761
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
Link dynamic routes - "href" and "as" prop - Unhandled Runtime Error Error (5.0.0-beta.4) #764
Comments
Duplicate of #413? |
@marteloge Yes, I believe so. |
@marteloge I think the solution provided in #413 (comment) should work for you. Maybe you can test and confirm since I want to open a PR for it this weekend. |
Seems to be working but I get a type error => Tested your solution:
The only problem I have is that I get a 404 on navigating with the LocaleLink: I do see the page after some magic, but I guess the 404 should not appear anyway? |
The I only tested this on v4.x.x so I'm not sure about the beta. In my case it works like a charm without any flash of a 404 page. Maybe you can create a codesandbox to demonstrate the issue (or MVP repo). I'll be happy to investigate and consider it when creating the PR to add this into core. |
@pixelass Great :) I have a test repo here you can check out: https://github.com/marteloge/inktemplate Just added your code to /pages/product/[name].js and swapped out <Link with the LocaleLink. |
Yeah to be clear, any PRs should be against the |
Product page: /pages/product/[name].tsx
I use Link imported from my i18n file.
In my component I use:
<Link href="/product/[name]" as="/product/test"><a>Test</a></Link>
This works perfectly with all other pages like my "/about" page.
Let's say I have selected Norwegian (language code: "no").
I want to look at the test product. The URL should then look like "/no/product/test".
When I click on the Link routing to my "test" product I get the error:
Unhandled Runtime Error
Error: The provided
as
value (/no/product/test) is incompatible with thehref
value (/product/[name]). Read more: https://err.sh/vercel/next.js/incompatible-href-asThe general link would be /product/test but as I use i18n the link is /no/product/test.
I could make the link as follows:
<Link href="/[lang]/product/[name]" as="/product/test"><a>Test</a></Link>
The problem with this is my default language (English: "en") does not have a language set in the URL.
When only using "href" without the "as" prop on dynamic links I get a 404:
<Link href="/product/test"><a>Test</a></Link>
The file fetched whit 404 response is http://localhost:3000/_next/static/development/pages/product/test.js. Right after
the test product page later is successfully fetched (http://localhost:3000/no/product/test).
--
Is there something I'm missing here or is this a bug?
I am testing the 5.0.0-beta.4 but I am not sure if it is related to the serverless beta version.
The text was updated successfully, but these errors were encountered: