-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Let devs define custom 404 page in Wasp #266
Comments
We could implement it like we implemented the app todoApp {
client: {
notFoundPage: import { NotFoundPage } from "@client/NotFoundPage.jsx"
}
} or app todoApp {
client: {
notFoundPage: NotFoundPage
}
}
page NotFoundPage {
component: import { NotFoundPage } from "@client/NotFoundPage.jsx"
} For React Router v5, we would need to define a new route like this: <Route path="*">
<NotFoundPage />
</Route> |
Maybe it would make more sense to define it for corresponding error codes? 500 / 404 / 403 / ... app todoApp {
client: {
404: import { 404 } from "@client/Errors",
500: import { 500 } from "@client/pages/errors/500"
}
} Also it would be cool to define single error page and get error/exception as prop to display error code/message/etc app todoApp {
client: {
error: import ErrorPage from "@client/ErrorPage",
}
} Then in ErrorPage export default function ErrorPage({ error }) {
return (<h1>Oh no {error->code} occurred</h1>);
} |
Yeah I like the last idea, that is probably the best! Aha wait, I know why we have special rule for 404 -> because that can happen by them going to wrong route and they can't handle that right now. Other errors they can't really get, those can come from server but they can handle them as they come, and as they like, in JS. Right? Or did I get something wrong here? Keep in mind this is an SPA. |
Yes, makes sense. I just through about handling errors but forgot that server lives separetely |
Should we by default already have some kind of 404 handler? I think so. |
The way users can implement wildcard routes in Wasp is quite simple, we might want to document this in the docs, or include it in our default template?
|
Just to mention that this likely then needs to be the last route in main.wasp file! |
User requesting this: |
The wildcard route is a way to go, but in the current Wasp implementation, the catch-all route triggers before the OAuth route we require by Wasp to finish the OAuth flow. We should probably move the Wasp defined routes at the first place so they don't get overridden by user-defined routes. |
No description provided.
The text was updated successfully, but these errors were encountered: