Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdmin - handle non-existing routes #768
Comments
|
I would like to work on this |
|
@amitsin6h Awesome! Let us know if you need help with the setup. Please consult the CONTRIBUTING guide to help you get started. We're also on https://gitter.im/Webiny/webiny-js if you need help. |
|
@doitadrian I followed your proposed solution steps and I added the plugin for |
|
Hi @Anshuman71, just tried this in our repo, this seems to work just fine: // apps/admin/App.tsx
import adminTemplate from "@webiny/app-template-admin-full";
import "./App.scss";
import { Route } from "@webiny/react-router";
import React from "react";
export default adminTemplate({
cognito: {
region: process.env.REACT_APP_USER_POOL_REGION,
userPoolId: process.env.REACT_APP_USER_POOL_ID,
userPoolWebClientId: process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID
},
plugins: [
{
type: "route",
name: "not-found-route",
route: <Route render={() => <div>Route not found!</div>} />
}
]
});So, to make this work on a more global level, and not only in your app, I would add the following route: <Route render={() => <Redirect to={opts.defaultRoute || "/"} />} />At this here reference: Let me know if you need more help! |
|
@Pavel910 thanks a lot. import adminTemplate from "@webiny/app-template-admin-full";
import "./App.scss";
import { Route } from "@webiny/react-router";
import React from "react";
export default adminTemplate({
cognito: {
region: process.env.REACT_APP_USER_POOL_REGION,
userPoolId: process.env.REACT_APP_USER_POOL_ID,
userPoolWebClientId: process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID
},
plugins: [
{
type: "route",
name: "not-found-route",
route: <Route render={() => <div>Route not found!</div>} />
}
]
});However, If I use the <Route component={() => <Redirect to={opts.defaultRoute || "/"} /> } />to That is the expected behavior and it solves the issue. |


This is:
Detailed Description
If a user opens a non-existing route in the Admin app, a blank page is shown.
Possible solution
Let's create a simple "Not found" page.
An example that shows how a default route is registered can be found here. So basically, it's a route that doesn't have the
pathprop defined.At this moment, I believe this route could be part of the
@webiny/app-adminplugins. If so, it should be added herepackages/app-admin/src/plugins/index.ts.