Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount react-admin under /admin

I simply want all of my admin pages to be under /admin.

<Admin
  title="Admin"
  dashboard={Dashboard}
  dataProvider={restClient}
  history={history}
>
  <Resource
    name="users"
    list={UserList}
  />
</Admin>

My main page is at /admin but when I click Users in the sidebar, it changes the path to /users and not /admin/users.

I'm using react-admin 2.0.0.

like image 620
swrobel Avatar asked Aug 23 '26 12:08

swrobel


1 Answers

The key is actually in the history prop passed to the Admin component:

import createHistory from 'history/createBrowserHistory';

const history = createHistory({ basename: '/admin' });

<Admin history={history} />
like image 128
swrobel Avatar answered Aug 26 '26 17:08

swrobel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!