Skip to main content
Version: v1 (Current)

Frontend routing and Ziggy

The platform uses Laravel named routes exposed through Ziggy, with a platform wrapper in resources/js/Composables/useZiggy.js. URL generation, route-set loading, HTTP transport and backend authorization are separate responsibilities. A generated URL does not grant access; a # result does not identify a permission failure.

Initial route sets​

Blade templates emit route definitions for their application context:

SurfaceInitial Ziggy group
Dashboard, authenticated ordinary administratordashboard
Dashboard, authenticated super administratorsystem-admin
Dashboard, logged outlogin
Developer Hubdeveloper
Portalportal

config/ziggy.php defines the groups. The dashboard group starts with * and excludes system, portal, Horizon, API and Waterline route-name patterns. Developer routes include developer.* and selected dashboard team-switch/navigation routes, with the configured version-pattern exclusion. Portal and login groups have their own explicit patterns/names. Do not assume every route is available in every client bundle.

To add a route needed before dashboard login, register the actual Laravel route and add its name/pattern to the login group when it is not already covered. Verify the logged-out template and refresh response can resolve it. Inclusion exposes route metadata; authentication, middleware, ownership and policies remain backend checks.

Use the platform wrapper​

Inside the initialized Vue/Pinia application:

import { computed } from 'vue'
import route from '@/Composables/useZiggy'

const href = computed(() => route('dashboard.dashboard'))
if (href.value !== '#') {
// Use the resolved URL with the intended link/navigation mechanism.
}

The wrapper signature is route(routeName, params, absolute = true). It passes the resolved route definition and parameters to Ziggy. It is a synchronous URL helper: it does not return a promise that waits for an unknown route to load.

When the route definition declares a parameter named exactly team, the wrapper fills an absent/falsy value, {{current_team}} or # from usePage().props.currentTeam, falling back to the current-team store. For a parameter named exactly project, it uses currentProject, then project from Inertia props. These are slug values. Supply explicit valid context when generating links outside the current selection.

This logic does not normalize teamSlug to team or projectSlug to project, or fill every parameter merely because its meaning is project-related. Match the exact registered route parameter names. Missing page/team context can cause resolution errors, which the wrapper catches and converts to #. The missing-project fallback is the string #; reading its .slug does not supply a valid project slug. Do not pass that absence off as a valid project identifier.

The wrapper can assign to the supplied parameter object when filling context. Use a fresh object when the caller should retain its original values. absolute = false is forwarded to Ziggy; choose it deliberately rather than string-editing an absolute URL to change hosts.

Missing routes and refresh​

useRoutesStore holds the current definitions, loading promise, retry counts and failed-route set. It starts from the emitted Ziggy configuration. Keep that initial configuration available before store creation; the source directly references the Ziggy global and is not an independent server-rendering bootstrap.

For a missing route, the wrapper can trigger fetchRoutes() and immediately returns #. The store fetches the relative URL /dashboard-routes using browser fetch, parses JSON and replaces its route collection. Concurrent refreshes share the in-flight promise. The wrapper does not itself await refresh or guarantee that every consumer reruns afterward; use a computed value such as the example above and verify the resulting link before enabling an action. For an explicit refresh, the store exposes the fetchRoutes() promise; resolve the desired route again after it finishes and still check for #.

Each route has a maximum of three wrapper-triggered attempts. At the limit it is marked failed and future wrapper calls return # before lookup. A successful refresh can clear failed entries if the refreshed collection contains the route. This is client state, not a permanent backend ban; another missing route/manual refresh or a new application lifecycle may change the collection. Do not implement an unbounded render/retry loop to conceal an invalid route name.

The refresh implementation parses response.json() without first checking response.ok. Network errors, HTML redirects or error JSON therefore need inspection in the Network panel; “fetch finished” does not prove a usable Ziggy collection. The initial and refreshed collections can also differ.

What /dashboard-routes returns​

The dashboard route is named dashboard.dashboard-routes and handled by ZiggyRoutesController.index:

  • No request user: login group.
  • Authenticated user with isSuperAdmin(): system-admin group.
  • Other authenticated user: dashboard group.

It does not select the developer or portal group based on the calling component. The store's relative fetch targets the current origin, so do not assume this dashboard refresh path is available on every portal/developer host. Check the actual application route registration and emitted template rather than using refresh as a universal way to import routes from another surface.

Route-group membership is not the effective permission map. A user may receive a route definition and still be denied its action. After identity/team context changes, verify fresh page props and the intended route set as well as backend authorization.

HTTP transport​

The dashboard helper @/Services/http is a configured Axios instance. It uses VITE_BASE_API_URL + '/', withCredentials: true, X-Requested-With: XMLHttpRequest and a browser x-timezone header from Intl.DateTimeFormat().resolvedOptions().timeZone.

A named route can resolve to an absolute host; inspect the final request URL instead of assuming the Axios base rewrites it. Credential inclusion is not CORS approval or proof of an authenticated session. The timezone header reports browser context, not necessarily the event timezone or a server-side conversion guarantee.

This helper does not automatically supply an installed App's dependency bindings or portal principal. Portal Apps should use their supported runtime store/API integration. See API integration (repository reference: /api-integration) and permissions and dependencies.

Verify and troubleshoot​

  1. Confirm the exact Laravel route name, method, domain and parameter names.
  2. Check the template's initial Ziggy group and the route entry in the current store.
  3. Inspect required team/project/resource values; verify they belong to the intended context.
  4. If resolution returns #, inspect loading/retry state and the actual /dashboard-routes response before allowing navigation or submission.
  5. Inspect the final URL/method, session/cookie context and backend response independently.
  6. Test an allowed principal and an intended denied principal; rendering a link is not an authorization test.
SymptomCheck
Logged-out action resolves to #Registered name, login group, emitted config and refresh response
Route exists server-side but not client-sideCorrect surface/group, exclusions and current route collection
Wrong team/project in linkExact parameter names, explicit values, current Inertia props/store and reused parameter objects
Refresh repeats then stopsPer-route three-attempt limit and failed-route set
Refresh returns HTML or unusable JSONCurrent origin, redirect/status and endpoint registration
Correct URL receives denialBackend principal, membership/effective action permission, ownership and resource binding
Dashboard helper fails in a portal AppUse the portal runtime contract rather than assuming dashboard routes/credentials

Source and verification scope​

Current entry points are useZiggy.js, Store/routesStore.js, Store/currentTeamStore.js, Services/http.js, config/ziggy.php, ZiggyRoutesController, dashboard route registration and the dashboard/developer/portal Blade templates. Existing HTTP-service tests mock Axios configuration; they do not prove cross-origin credentials, network delivery or denied-principal behavior. Verify application bootstrapping and host-specific route refresh in the target environment.