api-platform / admin

A beautiful and fully-featured administration interface builder for hypermedia APIs
https://api-platform.com/docs/admin/
MIT License
480 stars 130 forks source link

How to run the admin on a sub path #513

Closed herndlm closed 9 months ago

herndlm commented 9 months ago

Hi,

we're running API platform, including the admin and api part, on a sub path. I was able to configure the API properly and I found https://marmelab.com/react-admin/Routing.html#using-react-admin-in-a-sub-path for the admin

Our App currently looks like the following:

const App = () => (
  <BrowserRouter>
    <HydraAdmin
      basename="/dataprovider"
      disableTelemetry
      title="DataProvider"
      authProvider={authProxyAuthProvider}
      dataProvider={dataProvider}
      i18nProvider={i18nProvider}
      entrypoint={entrypoint}
      loginPage={false}
      layout={CustomLayout}
      requireAuth
    >
      <CustomRoutes>
        <Route
          exact
          path="/admin"
          element={<Admin />}
        />
        ,
      </CustomRoutes>
      <ResourceGuesser
        name="data_queries"
        edit={DataQueryEdit}
        create={DataQueryCreate}
        list={DataQueryList}
        show={DataQueryShow}
      />
    </HydraAdmin>
  </BrowserRouter>
);

The app is running on https://localhost:8060/dataprovider, when I open that react-admin properly redirects me to https://localhost:8060/dataprovider/data_queries. But the links on the left still use /data_queries and /admin. I should be able to adapt the admin, but how can I make the /data_queries work?

Am I missing something, or is some minor adaption here needed? If so, feel free to point me to it, I might be able to do it myself.

Many thanks!

herndlm commented 9 months ago

I think I figured it out. Fyi, I moved the basename prop up from HydraAdmin to BrowserRouter and now things seem to be fine.