Skip to content

Commit a6bffb0

Browse files
authored
Document how to get introspection to work on any route (#1808)
The previously documented solution would only trigger introspection on the `/` route. Users directly navigating to a resource without being authenticated (eg. navigating to `/#/books` and then being redirected to the authentication page) would not hit the `<Route path="/">`, and thus wouldn't trigger introspection after authenticating. If `redirectToLogin` is `true`, the `<Resource>`es shouldn't be defined in the application because otherwise they will register the specific routes, e.g. `/#/books`, meaning the `<Route path="/:any">` wouldn't be selected, and introspection also would not be triggered.
1 parent 03c7614 commit a6bffb0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

admin/authentication-support.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,17 @@ const Admin = () => {
7979
</Head>
8080

8181
<HydraAdmin dataProvider={dataProvider(setRedirectToLogin)} authProvider={authProvider} entrypoint={window.origin}>
82-
<CustomRoutes>
83-
{redirectToLogin ? <Route path="/" element={<RedirectToLogin />} /> : null}
84-
</CustomRoutes>
82+
{redirectToLogin ? (
83+
<CustomRoutes>
84+
<Route path="/" element={<RedirectToLogin />} />
85+
<Route path="/:any" element={<RedirectToLogin />} />
86+
</CustomRoutes>
87+
) : (
88+
<>
89+
<Resource name=".." list="..">
90+
<Resource name=".." list="..">
91+
</>
92+
)}
8593
</HydraAdmin>
8694
</>
8795
);

0 commit comments

Comments
 (0)