creativetimofficial / ct-black-dashboard-pro-react

Black Dashboard PRO React: A premium Boostrap & Reactstrap Admin Template
https://www.creative-tim.com/product/black-dashboard-pro-react
40 stars 18 forks source link

[Bug] Redirect to /admin/dashboard upon invalid route #23

Closed locmai0808 closed 4 years ago

locmai0808 commented 4 years ago

Version

1.0.0

Reproduction link

https://code.lnmai.com/#/admin/dashboard

Operating System

Windows

Device

Desktop

Browser & Version

Chrome 80

Steps to reproduce

  1. Go to https://code.lnmai.com/#/admin/dashboard
  2. Edit the url to something like https://code.lnmai.com/#/admin/invalid and press enter

    What is expected?

    Expected the app would redirect to https://code.lnmai.com/#/admin/dashboard instead of staying on https://code.lnmai.com/#/admin/invalid

    What is actually happening?

    App wont redirect upon invalid route.


Solution

Additional comments

According to your demo page here: https://demos.creative-tim.com/black-dashboard-pro-react/#/admin/dashboard When you go to https://demos.creative-tim.com/black-dashboard-pro-react/#/admin/invalid, it would redirect to dashboard, without refreshing the page.

lDLoUTb9SN

einazare commented 4 years ago

Hello there, @locmai0808 ,

I've checked our product and it works as expected. As I can see on the links you have given me, you have made changed to our product. Inside src/layouts/Admin/Admin.js inside the <Switch>...</Switch> component, you need to have a Redirect:

          <Switch>
            {this.getRoutes(routes)}
            <Redirect from="*" to="/admin/dashboard" />
          </Switch>

Also, please note this is not an issue with the product.

Best, Manu

locmai0808 commented 4 years ago

@EINazare Thanks! That fixed the issue.