qwik icon indicating copy to clipboard operation
qwik copied to clipboard

404 Page does not render

Open vloth opened this issue 3 years ago • 3 comments

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?

vloth avatar Oct 02 '22 11:10 vloth

Hello is it confirmed to fix? 🤔 Should we take it and fix it? :)

AlanLes avatar Oct 08 '22 18:10 AlanLes

Can we bump this? Pretty important feature :P

neuro-bro avatar Oct 19 '22 19:10 neuro-bro

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.

zanettin avatar Oct 29 '22 20:10 zanettin

Thanks, @zanettin

neuro-bro avatar Nov 23 '22 11:11 neuro-bro

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 🙏

zanettin avatar Feb 06 '23 22:02 zanettin

Just bumped into this with the static adapter, it doesn't seem to work with pnpm dev but does work with the production build.

cayter avatar Feb 08 '23 07:02 cayter

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.

edblocker avatar Feb 15 '23 12:02 edblocker

Does not work for me. On the latest version of Qwik.

y471n avatar Feb 25 '23 04:02 y471n

I will say that this is still valid and messed me up while I was working on an implementation for #2865

georgeiliadis91 avatar Feb 26 '23 09:02 georgeiliadis91

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.

jessezhang91 avatar Mar 01 '23 17:03 jessezhang91

@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]

RaeesBhatti avatar Mar 26 '23 16:03 RaeesBhatti

I can confirm this is still an issue in 0.100.0

EternallLight avatar Mar 31 '23 20:03 EternallLight

Still an issue in 0.101.0

mihai-stanimir avatar Apr 10 '23 12:04 mihai-stanimir

still a problem ? not working for me

realspinelle avatar Jul 01 '24 16:07 realspinelle

yes still a problem.. i also need the 500 error pages etc..

striderxfossility avatar Jul 01 '24 21:07 striderxfossility