Nested Access Policies
Part of the Routing and State section of Coddy's Vue journey. Lesson 48 of 55.
Parent metadata can declare a policy shared by nested routes. Vue Router exposes a merged to.meta for the matched hierarchy. A child that declares the same key overrides that top-level key in the merged result.
{path:'/member',component:MemberLayout,meta:{membersOnly:true},children:[
{path:'plans',component:Plans},
{path:'guide',component:Guide,meta:{membersOnly:false}}
]}Using the merged flag gives the application a clear override rule. An alternative policy such as checking whether any matched record requires access would behave differently and would not honor a false child override. Choose one contract and make public exceptions explicit.
Challenge
MediumProtect the nested member workspace through parent metadata. Parent /desk has requiresAuth: true; its empty Overview child and relative Plans child inherit that policy. Use the global metadata guard for both. Keep Help public, and show the workspace layout around either permitted child.
Keep the supplied route readout and bootstrap files.
Try it yourself
<!doctype html><html><head><meta charset="UTF-8"><title>Routing practice</title></head><body><div id="app"></div><script type="module" src="./main.js"></script></body></html>This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Routing and State
4Query State
Reading Query ValuesCommitting Search QueriesPreserving Other FiltersNormalizing Query NumbersRecap: Catalog Filters7Pinia Options Stores
Shared Store StateDerived Store GettersStore Actions and BoundsExtracting Reactive FieldsRecap: Seat Counter10Guarded Workflows
Store-Aware Access GuardsReturning After Sign-InNested Access PoliciesProtecting Unsaved DraftsRecap: Museum Pass2Navigation Actions
Navigation from HandlersReplacing HistoryHistory TravelCurrent Navigation LinksRecap: Save and Review5Nested Layouts
Parent and Child OutletsDefault Child ViewsRelative Child PathsAncestor Navigation StateRecap: Library Workspace8Store Design
Setup Store StructurePatching Related StateResetting Store StateComposing Related StoresRecap: Trip Pack11Workshop Planner Project
Planner RoutesShared Reservations