oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.02k stars 47 forks source link

404 route not working #170

Closed ufukbakan closed 2 months ago

ufukbakan commented 2 months ago

Describe the Bug

https://github.com/ufukbakan/vitex/tree/404

This project is Vite frontend template where the menu has a link to a non existing path. But instead of 404 page, an empty page is rendered. I wonder why? What am i missing?

Generouted Version

^1.19.5

Your Example Website or App or Reproduction

https://github.com/ufukbakan/vitex/tree/404

Steps to Reproduce the Bug or Issue

  1. Run the dev command
  2. Go to the web page that app served
  3. Click the Not Found link in the menu

Expected Behavior

I expected to see a h1 title that includes text "Not found" but instead i see an empty page.

Screenshots or Videos

image

Platform

Additional context

No response

oedotme commented 2 months ago

@ufukbakan the convention for the 404 route is to be at src/pages/404.tsx similar to the root _app.tsx layout

yokinox commented 2 months ago

@ufukbakan the convention for the 404 route is to be at src/pages/404.tsx similar to the root _app.tsx layout

Is it possible to have custom 404 page but with different _layout? Like this :

.
├── 404.tsx
├── _app.tsx
├── docs
│   ├── 404.tsx
│   ├── _layout.tsx
│   └── index.tsx
└── index.tsx

So, I want the 404.tsx inside docs directory will have same exact layout as it's parent.

oedotme commented 2 months ago

@yokinox the 404 convention is only available globally at src/pages/404.tsx directly.

You can use the dynamic catch-all convention to achieve the same result:

.
├── 404.tsx
├── _app.tsx
├── docs
│   ├── [...fallback].tsx
│   ├── _layout.tsx
│   └── index.tsx
└── index.tsx

https://github.com/oedotme/generouted?tab=readme-ov-file#dynamic-routes

yokinox commented 2 months ago

It works 👍

@yokinox the 404 convention is only available globally at src/pages/404.tsx directly.

You can use the dynamic catch-all convention to achieve the same result:

.
├── 404.tsx
├── _app.tsx
├── docs
│   ├── [...fallback].tsx
│   ├── _layout.tsx
│   └── index.tsx
└── index.tsx

https://github.com/oedotme/generouted?tab=readme-ov-file#dynamic-routes

It works 👍