Description Define a configuration to apply to a set of URLs
Synopsis routes: [ match: "url-prefix", can: 'ability' ]
Context Default server, VirtualHost, Route
Example routes: [ { match: '/public/' }, { match: '/auth/' } { match: '/members/', can: 'view' } { match: '/admin/', can: 'edit' }, { can: 'edit', redirect: '/auth/login' }, ],

The routes property specifies an ordered set of routes that defines the required authorization to be accepted.

A route entry has a match property that defines the URL prefix that must match for the route to be used.

The optional "can" property defines a set of "abilities" the user must possess for the route to be used. If the "can" property is absent, all users will match. If specified, the user must be authenticated first to determine their abilities.

If the route matches, but the user fails to be authorized, the "redirect" property will be used to redirect the user to the given URL.

Ioto tests routes in order and the first matching route is used. If no routes match, the client request is rejected with a 401 status code.

© Embedthis Software. All rights reserved.