-
-
Notifications
You must be signed in to change notification settings - Fork 167
refactor: provide 404.html without fs access #1714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
refactor: provide 404.html without fs access #1714
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"I don't think app.notFound handler is actually triggered" - it is triggered when requesting a page that is not matched by the router on the initial html request. https://waku-c3-test.martiandev.workers.dev/this-page-does-not-exist
| import fs from 'node:fs'; | ||
| import { DIST_PUBLIC } from '../constants.js'; | ||
| import { INTERNAL_setAllEnv } from '../../server.js'; | ||
| import notFountHtml from 'virtual:vite-rsc-waku/404'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notFountHtml typo. It should be notFoundHtml.
To clarify, my statement "app.notFound handler is actually triggered" is for the case when |
Ah, yes. Sorry. You are right. I always forget about the src/pages/404.tsx pattern. I confirmed adding that always renders the 404.tsx and does not hit the app.notFound. Maybe we should add src/pages/404.tsx to the templates in the It would be good to be able to render it during build to dist/assets/404.html. Most static hosting platforms can be configured to use a custom 404.html page. I confirmed that if define only static pages and layouts, I can delete the |
|
Thanks for confirming. Yeah, so this means
Isn't it already working like this? if |
I see. It will do that if public/404.html does not also exist. Right. 😄 |
In Both static mode and non-static mode, |
WIP
I think this can be minor cleanup. Interestingly
dist/public/404.htmlmight be the result of ssg-ingsrc/pages/404.tsx, but when non static mode, 404 is already handled by the router, so I don't thinkapp.notFoundhandler is actually triggered?