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

notFound(); not working with head.js in same folder #45385

Open
1 task done
shuffgy opened this issue Jan 29, 2023 · 6 comments
Open
1 task done

notFound(); not working with head.js in same folder #45385

shuffgy opened this issue Jan 29, 2023 · 6 comments
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template.

Comments

@shuffgy
Copy link

shuffgy commented Jan 29, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Wed Nov 23 01:01:46 UTC 2022
Binaries:
  Node: 16.11.1
  npm: 8.0.0
  Yarn: 1.22.15
  pnpm: N/A
Relevant packages:
  next: 13.1.6
  eslint-config-next: 13.1.6
  react: 18.2.0
  react-dom: 18.2.0

I have a /blog/[slug]/page where i call notFound() to create a custom 404 page. But i get errors in my head.js.
As soon as i delete my head.js in /blog/[slug]/head.js the function works fine.

Am I missing something?

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true), Head component/file (next/head / head.js)

Link to the code that reproduces this issue

https://vscode.dev/github/Gawdfrey/next-not-found-reproduction/blob/777c646c71c63e4ee15c88bf65ec0149c6ce3d23

To Reproduce

Add a head.tsx or .js in the same folder where notFound() is fired in page.tsx

Describe the Bug

Getting NEXT_NOT_FOUND when trying to implement notFound() in my [slug]/page.tsx.

Expected Behavior

It should render the content of not-found.tsx.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@shuffgy shuffgy added the bug Issue was opened via the bug report template. label Jan 29, 2023
@Gawdfrey
Copy link

I attempted this as well, and after adding the head.tsx I had no issue using the notFound function in the page file, that rendered the not-found ui I wanted. But using the notFound function in the head.tsx file only returned the NEXT_NOT_FOUND error.

@balazsorban44 balazsorban44 added the area: app App directory (appDir: true) label Jan 31, 2023
@EduardoSCosta
Copy link

i'd like to investigate this issue

@EduardoSCosta
Copy link

EduardoSCosta commented Feb 10, 2023

I was unable to reproduce the case mentioned in the issue:

I have a /blog/[slug]/page where i call notFound() to create a custom 404 page. But i get errors in my head.js.
As soon as i delete my head.js in /blog/[slug]/head.js the function works fine.

But I managed to reproduce the one mentioned by @Gawdfrey, and maybe in this case it is intentional?

head.js should only return to the following tags: <title>, <meta> , <link> (with the precedence attribute) or <script> (with the async attribute).

Anymay, looks like head.js will be deprecated soon:

Built-in support for SEO through metadata is available on next@canary. This replaces the previous head.js implementation. The head.js special file will be deprecated in 13.2 and removed in a future version. Learn more.

@Gawdfrey
Copy link

That is probably true! But yeah, it will be deprecated soon

@christo9090
Copy link

Came here to say that I am having the same issue but learned about the deprecation. I've had a couple of different issues with fetching data in the head file so that's probably a good move.

@karlhorky
Copy link
Contributor

karlhorky commented Mar 29, 2023

Since head.tsx / head.js is gone and deprecated now, I guess this issue can be closed - @shuffgy, what do you think about closing this?


If anyone else is having issues with not-found.tsx / error.tsx files not working with the new metadata and generateMetadata exports, then you may want to take a look at these issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

6 participants