Edit Page

config/routes.js

This file contains custom routes. Sails uses these routes to determine what to do each time it receives a request.

If Sails receives a URL that doesn't match any of the custom routes in this file, it will check for matching assets (images, scripts, stylesheets, etc.). Finally, if those don't match either, the default 404 handler is triggered.

When you first generate your Sails app, there is only one route in this file. Its job is to serve the home page.

You'll probably want to add some more.

Sails also injects shadow routes, or implicit routes that handle certain kinds of requests behind the scenes. For more information about these kinds of routes, see Concepts > Blueprints.

Usage

#

See sails.config.routes for all available options.

Want to see for yourself?

An example of this file can be found in our sample app repo, here.

Anatomy of a Sails App