Upgraded from 6.2.3 to 7.0.0-canary.347 and getting this error:
You must specify an `unauthenticated` route when marking a Route as private
I have to private routes in my Router.tsx - here’s an abbreviated version of it.
Notice that I have specified an unauthenticated route for both of my two private routes. Any idea what I’m doing wrong here?
<Router useAuth={useAuth}>
<Route path="/auth" page={AuthPage} name="auth" />
<Private unauthenticated="auth" whileLoadingPage={Loader} whileLoadingAuth={Loader}>
<Route path="/delivery/{slug}" page={DeliveryPage} name="delivery" />
<Set wrap={NavLayout}>
<Private roles="admin" unauthenticated="dashboard">
<Route path="/billing" page={BillingPage} name="billing" />
</Private>
...........
Ok I figured it out just after posting this (of course).
Apparently the canary has an issue with the nested Set
under the Private
route
Updated it so that they’re not nested (see below) and everything works as expected.
<Router useAuth={useAuth}>
<Route path="/auth" page={AuthPage} name="auth" />
<Private unauthenticated="auth" whileLoadingPage={Loader} whileLoadingAuth={Loader}>
<Route path="/delivery/{slug}" page={DeliveryPage} name="delivery" />
</Private>
<Private wrap={NavLayout} unauthenticated="auth" whileLoadingPage={Loader} whileLoadingAuth={Loader}>
<Private roles="admin" unauthenticated="dashboard">
<Route path="/billing" page={BillingPage} name="billing" />
</Private>
dom
September 20, 2023, 7:06pm
3
Hey @nathanmacfarlane , we did recently merge a fix that went out in a recent canary aimed at fixing a bug with private routes:
redwoodjs:main
← redwoodjs:kc-fix-9131
opened 08:27AM - 19 Sep 23 UTC
Fix for #9131
This handles use cases where there are multiple nested routes w… ith different levels of authentication and redirect contexts
So we’ll take a look and see if we missed something, thanks!
danny
October 15, 2023, 8:04am
4
Confirming this is a real bug :), will try and have a solution for this!
In the mean time, thank you for the workaround and the report @nathanmacfarlane
Tobbe
October 16, 2023, 6:09am
5
I think I just ran into this issue myself. I wrote up an issue for it [Bug?]: Props from nested sets are propagating up to parent sets · Issue #9304 · redwoodjs/redwood · GitHub
It might not look exactly the same, but I think the root cause is the same.