404 Page does not render
Qwik Version
0.9.0
Operating System (or Browser)
MacOS
Node Version (if applicable)
v16.14.2
Which component is affected?
Qwik City
Expected Behaviour
Creating a 404.{tsx,mdx} file under src/routes should render it, when route is not found.
Actual Behaviour
Always renders the default 404 page, it seems like the custom page is skipped.
Additional Information
It's more like an assumption coming from other frameworks and reading some issues & codes here, but shouldn't a 404 be rendered when route is not found? (I didn't find how to do it otherwise from the docs) Maybe I am missing something?
Hello is it confirmed to fix? 🤔 Should we take it and fix it? :)
Can we bump this? Pretty important feature :P
Hi there
As a workaround till it is implemented: i solved it by adding a catch all route and setting the status code manually on a onGet handler like:
export const onGet: RequestHandler = async ({ params, response }) => {
if ( ....) {
response.status = 404;
return {};
}
return ...
}
If you would like to implement it on a PR imo this would be the file to start with: https://github.com/BuilderIO/qwik/blob/main/packages/qwik-city/middleware/request-handler/error-handler.ts#L12
I can't really test it locally but shouldn't be too hard to check if a file exist in the pages directory which matches the status code before rendering the minimal version defined in the above mentioned files.
Thanks, @zanettin
Hi @neuro-bro Wanted to check, if this issue is still present or if https://github.com/BuilderIO/qwik/pull/2175 fixed it for you as well 😄 please let me know, if you have any further questions or feel free to close the issue 🙏
Just bumped into this with the static adapter, it doesn't seem to work with pnpm dev but does work with the production build.
I came into this issue after following the docs (https://qwik.builder.io/qwikcity/advanced/routing/#custom-404-page) as well. However this doesn't work in a dev setting, nor a production build for me. I upgraded to the latest qwik and qwik-city, but a custom 404.tsx in the routes directory does nothing so far.
Does not work for me. On the latest version of Qwik.
I will say that this is still valid and messed me up while I was working on an implementation for #2865
I just experimented with this a bit. I'm using the express adapter and noticed going through the code here that if I have an ssg config:
expressAdapter({
ssg: {
// TODO: hacky to make it generate 404 pages
include: [''],
exclude: ['*'],
}
}),
set, it will generate my 404 pages.
Looking at the dev server code, it seems that just always renders the qwik error pages. See here and here.
@manucorporat Could you please provide some context on why this is closed! Is there an unreleased fix for this? This is still an issue in @builder.io/[email protected] + @builder.io/[email protected]
I can confirm this is still an issue in 0.100.0
Still an issue in 0.101.0
still a problem ? not working for me
yes still a problem.. i also need the 500 error pages etc..