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

Fix runtime errors by removing as prop from Link #200

Merged
merged 16 commits into from
Jan 8, 2025
Merged

Conversation

ProchaLu
Copy link
Member

@ProchaLu ProchaLu commented Jan 7, 2025

Closes #197

Using both href and as in the Link component caused errors in the production build:

[WebServer]  ✓ Starting...
[WebServer]  ✓ Ready in 343ms
Running 1 test using 1 worker
[WebServer]  ⨯ TypeError: The "path" argument must be of type string. Received undefined
[WebServer]     at h (.next/server/chunks/984.js:1:10103)
[WebServer]     at p (.next/server/app/[contentType]/[slug]/page.js:1:6489)
[WebServer]     at f (.next/server/app/[contentType]/[slug]/page.js:1:6599) {
[WebServer]   code: 'ERR_INVALID_ARG_TYPE',
[WebServer]   digest: '1055278411'
[WebServer] }

This PR fixes the runtime errors during navigation in the production build by simplifying the Link component and removing the as prop. Since Next.js v10.0.0, href props pointing to a dynamic route are automatically resolved, making the as prop redundant.

"href props pointing to a dynamic route are automatically resolved and no longer require an as prop."

Additionally this PR Set metadataBase URL in metadata generation to remove this warning during build.

⚠ metadataBase property in metadata export is not set for resolving social open graph or twitter images, using "http://localhost:3000/". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase

@ProchaLu ProchaLu self-assigned this Jan 7, 2025
Copy link

netlify bot commented Jan 7, 2025

Deploy Preview for dancing-dragon-b13f72 ready!

Name Link
🔨 Latest commit e516ce2
🔍 Latest deploy log https://app.netlify.com/sites/dancing-dragon-b13f72/deploys/677e5f175b38850008737bb1
😎 Deploy Preview https://deploy-preview-200--dancing-dragon-b13f72.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ProchaLu ProchaLu changed the title Set metadataBase URL in metadata generation Use Next.js static rendering for Markdown content Jan 7, 2025
@ProchaLu ProchaLu changed the title Use Next.js static rendering for Markdown content Convert from static rendering to server-side rendering Jan 7, 2025
@karlhorky
Copy link
Member

As discussed offline:

  1. This PR is probably larger than it needs to be - let's make this the smallest code change possible to fix the issue
  2. Let's avoid moving away from static rendering if we can - that means either:
    1. Continuing to use generateStaticParams
    2. Using the new experimental.dynamicIO and 'use cache' APIs

@ProchaLu ProchaLu changed the title Convert from static rendering to server-side rendering Fix runtime errors by removing as prop from Link Jan 8, 2025
Copy link
Member

@karlhorky karlhorky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@ProchaLu ProchaLu enabled auto-merge (squash) January 8, 2025 11:36
@ProchaLu ProchaLu merged commit f20344d into main Jan 8, 2025
3 checks passed
@ProchaLu ProchaLu deleted the add-metadataBase branch January 8, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error during Playwright tests: TypeError: The "path" argument must be of type string. Received undefined
2 participants