Root `not-found.tsx` stopping static rendering of HTML
Answered
Mrigal carp posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Mrigal carpOP
Hi, I'm making use of dynamic route segments in an app with the following structure
The
I wanted to customise the 404 behaviour, so I added a
This all works fine in dev mode, however when I build the app no
If I remove the root
Has anyone seen anything like this before? Have I misunderstood what the
app/
├─ [...filters]/
│ ├─ page.tsx
├─ search/
│ ├─ page.tsx
├─ not-found.tsx
├─ page.tsx
├─ layout.tsx
The
[...filters]
segment makes use of generateStaticParams
to generate a set list of routes, and sets dynamicParams
to false
so that the app will throw a 404 if a non-generated route is visited. I wanted to customise the 404 behaviour, so I added a
not-found.tsx
file to the root of the app that will, depending on the path trying to be accessed, either redirect to the search
segment, or show a custom 404 message.This all works fine in dev mode, however when I build the app no
.html
files are generated for the routes produced by the [...filters]
segment's generateStaticParams
call. If I remove the root
not-found.tsx
file, the .html
files are generated for all expected routes.Has anyone seen anything like this before? Have I misunderstood what the
not-found.tsx
root file is for? Thanks for any help.Answered by Mrigal carp
Ah ok, so it looks like because my
not-found.tsx
file is accessing headers it's stopping the dynamic routes from being statically rendered2 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Mrigal carpOP
Hmm, the issue seems to be fixed in the current
canary
release![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Mrigal carpOP
Ah ok, so it looks like because my
not-found.tsx
file is accessing headers it's stopping the dynamic routes from being statically renderedAnswer