[BUG] `404` status not working with dynamic routes
Describe the bug
Routes that don't exist and are matched by a catch all route render the NotFound component but return a 200 status.
This happens even if the response status is modified within the actual route component before even rendering the NotFound component.
The responses look identical when logged, but the actual status is different in the console and browser.
Static route that returns a 404 status:
HydrogenResponse [Response] {
size: 0,
timeout: 0,
wait: false,
sent: false,
cacheOptions: { mode: 'public', maxAge: 1, staleWhileRevalidate: 9 },
status: 404,
statusText: 'Not found',
url: 'http://localhost:3001/404',
[Symbol(Body internals)]: { body: null, disturbed: false, error: null },
[Symbol(Response internals)]: {
url: undefined,
status: 200,
statusText: 'OK',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: undefined
}
}
Dynamic route that returns a 200 status:
HydrogenResponse [Response] {
size: 0,
timeout: 0,
wait: false,
sent: true,
cacheOptions: { mode: 'public', maxAge: 1, staleWhileRevalidate: 9 },
status: 404,
statusText: 'Not found',
url: 'http://localhost:3001/collections/freestyle-404',
[Symbol(Body internals)]: { body: null, disturbed: false, error: null },
[Symbol(Response internals)]: {
url: undefined,
status: 200,
statusText: 'OK',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: undefined
}
}
To Reproduce
- Navigate to https://www.hydrogen.shop/404
- Notice 404 status
- Navigate to https://www.hydrogen.shop/collections/freestyle-404
- Notice 200 status
Expected behaviour
Dynamic routes that don't exist should return a 404 status.
Screenshots

Additional context Add any other context about the problem here. eg.
- Hydrogen version
1.5.0and1.6.0 - Node version
16.18.0 - Device details
Linux Manjaro Sikaris 22.0.0
I can also confirm on y side that there is a hydration error. Is there a fix?
The error may be more related to the Script tag. I tried using another third-party script, which still gave me hydration errors. I also believe that hydration errors start to appear when you do dangerouslySetInnerHTML. I loaded a script with only src and there were no issues.